AFAICS you are using the LV_ITEM.lParam of the items as a index. After the first (correct) sorting these indexes are invalid - I would store a pointer to the string (or a structure) in LV_ITEM.lParam to solve this problem.
Yes, it seems that these indexes become invalid. Keeping the original index in lParam was actually my initial approach, and it does seem to work better (besides, it works perfectly for size & date).
Here are lines 426ff of the attachment:
mov ecx, Files$(lp1)
; get ptr to file, 0-based index in lp1+lp2 if useSD ; use StringsDiffer or lstrcmpi?
void
StringsDiffer(ecx, Files$(lp2), 1)
; 1=case-insensitive if 0
test eax, eax ; activate to simulate lstrcmpi behaviour
.if Sign?
or eax, -1
.elseif eax
mov eax, 1
.endif
endif
Now the weird thing is again that
a) it works fine ascending, but the descending version has usually one item that is inserted in the wrong location.
b) if I use lstrcmpi (returning -1/0/1) it sorts exactly once... 8)
P.S.: Just saw your edit - thanks a lot :t
Your version does not show the wrong sorting behaviour, but the size & date columns do no longer work... will see 8)
P.P.S.: It seems I got it, see attachment. Stupid noob bug :redface: