Incorrect sort order

Viewing 2 reply threads
  • Author
    Posts
  • November 9, 2019 at 10:14 AM #37958

    Greg Maletic
    Participant

    I have a “year” field in my database of 190 records. It’s a text field — not a numeric field — because I occasionally include date ranges (“1970-1978”) or a question mark (“197?”).

    When I sort based on year, the sort order seems to be incorrect in a few cases. Here’s the sort order I notice:

    ?
    196?
    197?
    198?
    1940-1954?
    1960
    1960?
    1964
    1966
    1969
    1970
    1971
    …and so on

    This mostly seems correct, but I can’t make sense of why “196?”, “197?”, and “198?” are listed 2nd, 3rd, and 4th in this list. Alphabetical order would dictate they come later.

    I’m using Version 5.3.8 (Build 1821)

    November 10, 2019 at 2:39 AM #37985

    Brendan
    Keymaster

    When Tap Forms sorts the strings, it uses a function called localizedStandardCompare when comparing values to be sorted. This sorting order would be the same sorting order that you see in files in the Finder.

    I did a test of your values and I found the Finder is sorting them exactly the same way. See attachment.

    So that explains why it’s sorting that way.

    Attachments:
    You must be logged in to view attached files.
    November 13, 2019 at 12:13 AM #38019

    Greg Maletic
    Participant

    Thank you. Now that I look at it, I suppose macOS is seeing my strings “196?”, “197?”, etc. as the numbers “196” and “197”, which would understandably sort before “1940”.

Viewing 2 reply threads

You must be logged in to reply to this topic.