Skip to main content
Participating Frequently
Jun 5, 2023 4:04 PM UTC
Question

BUG: Underscore sorts to the bottom of a list

I'm in the appian designer and I'm trying to sort my datasets by description.

Normally if you use an underscore "_" as the first character, entries with the "_" as its first character will appear at the top of the list when sorting alphabetically.

Not with Appian however 

Anything with an "_" as its first character sorts to the bottom of the list, not the top.

Example 

Any Name
Bny Name
Cny Name
_ny Name

Why? No one else seems to do it this way. I've worked with dozen of applications and none of them sort the "_" character last like this. 

Is this a bug or is Appian taking a page from MS' playbook and assumes that it knows better than everyone how sorting should work?

How can I fix this or find a work around? I don't want to resort to using 1, 2, 3... in order to force my descriptions to sort properly.

    10 replies

    mikes0011
    Brainy
    Jun 5, 2023 4:18 PM UTC

    The ASCII character code for underscore is 95, whereas for the uppercase letters it's 65 - 90 (so, lower).  I assume Appian does a simple sort along these lines, and I personally wouldn't have any expectation that it do anything different unless otherwise specified.  Especially for a plaintext field like description.

    Also to confirm, I'd be curious whether underscore sorts *higher* than lowercase letters, since their ascii codes are higher(?)

    The Expression Guru
    stewart.burchell
    Employee
    Jun 5, 2023 4:20 PM UTC

    Interesting...can you show how you're attempting to conduct your sorting? I've just tried this (see sample code below) and it works as you describe it should:

    a!localVariables(
      local!list: {
        a!map(value: "Any Name"),
        a!map(value: "Bny Name"),
        a!map(value: "Cny Name"),
        a!map(value: "_ny Name")
      },
      fn!todatasubset(
        arrayToPage: local!list,
        pagingConfiguration: a!pagingInfo(
          startIndex: 1,
          batchSize: -1,
          sort: a!sortInfo(
            field: "value",
            ascending: true
          )
        )
      )
    )

    mikes0011
    Brainy
    Jun 5, 2023 4:32 PM UTC

    I assume it kinda depends on what he meant by "sort my datasets by description" in the OP - but I'm not sure what "data sets" it involves, or what "description" -- is this querying on a DB field?  Sorting appian objects by their literal "description" field?  Something else?  I'm pretty unclear.

    The Expression Guru
    Participating Frequently
    Jun 5, 2023 10:50 PM UTC

    To Reproduce

    • Go to the Appian Designer
    • Click on Any Application
    • Click on Build

    That Description - the one right between the Name and Last Modified columns.

    I guess this is a Unix thing because Microsoft, Excel, Google Drive, Google Sheets, and a pile of other programs sort the "_" character first along with !, #, $ etc. even thou its between the Upper and Lower case letters on an Ascii chart. 

    I can use !_ to get the sort order I'm looking for since the ! is a lower ascii value than both numbers and letters.

    Its more an OCD thing as I use the "_" character a lot in order to force a sort order without having to jump through hoops. I was expecting to sort near the top of the sort order like these other programs do.

    mathieud0001
    Genius
    Jun 6, 2023 12:00 AM UTC

    Works for me in designer for me as well. This one is certainly interesting. Wonder if it perhaps has something to do with the collation on the server?

    https://docs.appian.com/suite/help/23.2/Prerequisites.html#verify-the-server-system-locale-setting