Search the Community
Showing results for tags 'ListView Sort'.
-
Not Newbie to coding, but have not used listview many times, and callback sorts even less First time posting code with tags, hope this is readable... FYI - I'm trying to sort time, and my solution is to convert time to ticks in a column that will eventually be out of view and when user sorts the "00:00:00" column, i'll sort the hidden ticks column instead. Problem: Can't get it tho, why this code is producing odd sorting results in my listview The console shows proper evaluation of each numerical comparison. Func LVSort($hWnd, $nItem1, $nItem2, $nColumn) Local $nSort, $val1, $val2, $nResult ; Switch the sorting direction If $nColumn = $nCurCol Then If Not $bSet Then $nSortDir = $nSortDir * - 1 $bSet = 1 EndIf Else $nSortDir = 1 EndIf $nCol = $nColumn $val1 = GetSubItemText($hWnd, $nItem1, $nColumn) $val2 = GetSubItemText($hWnd, $nItem2, $nColumn) ; If it is the 3rd colum (column starts with 0) then compare the dates If $nColumn = 2 Then $val1 = StringRight($val1, 4) & StringMid($val1, 4, 2) & StringLeft($val1, 2) $val2 = StringRight($val2, 4) & StringMid($val2, 4, 2) & StringLeft($val2, 2) EndIf if $nColumn = 2 Then ; ConsoleWrite($Val1 & " " & $Val2 & @CRLF) If Number($val1) < Number($val2) Then $nResult = -1 ; Put item2 before item1 ConsoleWrite($Val1 & " < " & $Val2 & @CRLF) Else $nResult = 1 ; Put item2 before item1 ConsoleWrite($Val1 & " > " & $Val2 & @CRLF) EndIf EndIf If $val1 < $val2 Then $nResult = -1 ; Put item2 before item1 ElseIf $val1 > $val2 Then $nResult = 1 ; Put item2 behind item1 EndIf $nResult = $nResult * $nSortDir Return $nResult EndFunc ;==>LVSort Results in my list are... um, confusing. 90061000 315000 122560000 1224610000 1061000 10000 1000 100 10 0 PS why is there no emoticon for coffee, or pizza?