Select to view content in your preferred language

Sort GlobalID field in attribute table

265
4
02-04-2025 12:28 AM
Status: Open
Labels (1)
ChristianAmrhein1
Occasional Contributor

In an attribute table, all columns can be sorted ascending and descending. This only does not work for a GlobalID field. We would like the sorting function to also work correctly for GlobalIDs.

4 Comments
JEMOO-01

Hi Christian, 

Understanding the GlobalID Field: The GlobalID field is a crucial element in geodatabases, serving as a unique identifier for each record. This field ensures data integrity and is especially important for maintaining relationships between tables and synchronizing edits in distributed environments.

Why GlobalID Sorting is Limited: The primary reason sorting by GlobalID may not be as straightforward as other fields is due to its inherent role in data management. The GlobalID field typically uses a unique, system-generated identifier (UUID) for each record, which isn't designed for user-friendly sorting.

Additional Idea: 

  •  Creating a New Field in Text Datatype --> [ GlopalIDSorting ] Then Calculate the data from GlopalID Field into new field
  • Sorting it [ Asc ] or [ Desc ] As you need 

 

*Notes : 

Sorting text that contains a mix of numbers, letters, and signs (also known as alphanumeric sorting) follows a specific sequence. This sequence is typically based on the ASCII values of the characters and is commonly referred to as "lexicographical order" or "dictionary order." Here's the general order of sorting:

  1. Symbols: Special characters and punctuation marks (e.g., !, #, &, @).

  2. Numbers: Digits are sorted numerically (0-9).

  3. Uppercase Letters: Uppercase alphabetic characters (A-Z).

  4. Lowercase Letters: Lowercase alphabetic characters (a-z).

ChristianAmrhein1

Hi Jemoo

Thank you very much for the information! We successfully use the workaround with the text field. That works well - for sorting as for searching. Nevertheless, it would be interesting if the GlobalID field itself could also be sorted... even if it would require a little more logic in the background?

JEMOO-01

Thank you for your feedback! I'm glad to hear that the workaround with the text field is working well for sorting and searching.

As mentioned earlier, the GlobalID field is designed to be a unique identifier that is generated randomly to ensure the integrity and uniqueness of each record. While it's theoretically possible to implement more complex logic to sort GlobalIDs directly.

DavidSolari

The GlobalID column technically sorts correctly, the issue is the byte ordering of the raw GUID data vs. the standard presentation. If I use data stored in a SQL Server EGDB it's sorted per the SQL Server uniqueidentifier type as described in this blog post, which is why it doesn't appear sorted. I couldn't tell you if every EGDB host has their own behavior or if ArcGIS in forcing everything to sort like uniqueidentifier but there is a method to the madness.