KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Collection .sort() Function
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: December 20, 2022

The 4D Collection class has a sort function that will return a new sorted collection. Because collections can contain a mix of value types, the sort has a specific ordering.

The order prioritizes first the types:

    1) null
    2) booleans
    3) strings
    4) numbers
    5) objects
    6) collections
    7) dates
Then within each group the values are sorted.

This should be kept in mind when using the default sort function. A method can be applied for a custom form of
sorting, or if a specific type is needed, the collection can be filtered.