Talk:Natural sorting: Difference between revisions

Content added Content deleted
(Undo revision 245762 by Petelomax (talk))
Line 13: Line 13:
No field is ignored Donal.
No field is ignored Donal.
# Split the string into fields of alternating numeric/non-numeric runs of characters (or non-numeric/numeric).
# 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 ['''erm, leftmost''' [[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 19:07, 7 April 2017 (UTC)] 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).
# 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 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.
# 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.