Talk:Natural sorting: Difference between revisions

Undo revision 245761 by Petelomax (talk)
(Undo revision 245762 by Petelomax (talk))
(Undo revision 245761 by Petelomax (talk))
Line 14:
# Split the string into fields of alternating numeric/non-numeric runs of characters (or non-numeric/numeric).
# when comparing two strings s1 and s2 say, now split as fields, start from the rightmost fields and compare them - if the first fields are numeric then compare them as integers; if the fields are both non-numeric then compare them as character strings; if they differ in type then assume any integer field is always less than any non-integer field (the two strings shouldn't really be compared, but this gives them a defined order).
# If the two rightmost ['''erm, leftmost''' [[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 19:03, 7 April 2017 (UTC)] fields are equal then compare the next two fields, and so on.
# If the fields of the two strings compare equal so far, but one string has no more fields but the other has more fields, then the string with least fields is the smaller.
Using the above comparison rules you should be able to sort/order strings. --[[User:Paddy3118|Paddy3118]] 19:11, 23 April 2011 (UTC)
Line 70:
 
I would expect the natural sort to give the reverse order, based on evaluating the groups from the right. -- [[User:Peter|Peter]] 00:20, 17 Feb 2017 (UTC)
 
Hello Peter, a different Peter here. The neat completeness of 1..4 may be beguiling, but for instance add foo3baz99bar9.txt to that last list. I cannot think of a single example where sorting words left to right but numbers right to left would make it easier for a human to find anything. Surely the "rightmost" in 3 above is just a simple typo and should always have said leftmost - in fact I have decided to plant an edit right on it. [[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 19:03, 7 April 2017 (UTC)
 
==Criticisms please==
7,794

edits