Talk:Natural sorting: Difference between revisions
Content added Content deleted
m (Test strings) |
(→Numeric sub-fields: puzzled.) |
||
Line 23: | Line 23: | ||
::: That's what <code>[http://www.tcl.tk/man/tcl8.5/TclCmd/lsort.htm#M6 lsort -dictionary]</code> does. (Well, it also handles case a bit differently, treating it as a second-order difference rather than the usual first-order difference.) It was added because it is the mode which “puts filenames in the order that the user expects”, making it much easier to produce a nice GUI to use. (FWIW, I'm not doing the ligature normalization stuff because that's a lot of work to do right and it's an area where Tcl needs more work; I forget the Request For Enhancement number. :-)) –[[User:Dkf|Donal Fellows]] 11:17, 2 May 2011 (UTC) |
::: That's what <code>[http://www.tcl.tk/man/tcl8.5/TclCmd/lsort.htm#M6 lsort -dictionary]</code> does. (Well, it also handles case a bit differently, treating it as a second-order difference rather than the usual first-order difference.) It was added because it is the mode which “puts filenames in the order that the user expects”, making it much easier to produce a nice GUI to use. (FWIW, I'm not doing the ligature normalization stuff because that's a lot of work to do right and it's an area where Tcl needs more work; I forget the Request For Enhancement number. :-)) –[[User:Dkf|Donal Fellows]] 11:17, 2 May 2011 (UTC) |
||
:::: Thanks. --[[User:Paddy3118|Paddy3118]] 23:26, 2 May 2011 (UTC) |
:::: Thanks. --[[User:Paddy3118|Paddy3118]] 23:26, 2 May 2011 (UTC) |
||
I'm not understanding this algorithm. Copied from the Python results, |
|||
<pre> |
|||
Naturally sorted: |
|||
['Equiv.\x0bspaces: 3+0', |
|||
'Equiv.\nspaces: 3+1', |
|||
'Equiv.\tspaces: 3+2', |
|||
'Equiv.\x0cspaces: 3-1', |
|||
'Equiv.\rspaces: 3-2', |
|||
'Equiv. spaces: 3-3'] |
|||
</pre> |
|||
Each of these strings ends in a sub-field of digits, actually a single digit, and the sub-field before that is either "+" or "-". Starting with the right-most subfields, they will be ordered by their integer values, 0, 1, 2, or 3. Then for cases with the same value, "+" comes before "-" by usual string comparison. That's enough to discriminate these strings. The remaining left-most sub-fields don't need to be considered. So, shouldn't the correct order be, |
|||
<pre> |
|||
'Equiv.\x0bspaces: 3+0', |
|||
'Equiv.\nspaces: 3+1', |
|||
'Equiv.\x0cspaces: 3-1', |
|||
'Equiv.\tspaces: 3+2', |
|||
'Equiv.\rspaces: 3-2', |
|||
'Equiv. spaces: 3-3' |
|||
</pre> |
|||
I'm missing something —[[User:Sonia|Sonia]] ([[User talk:Sonia|talk]]) 22:32, 25 July 2014 (UTC) |
|||
==Criticisms please== |
==Criticisms please== |