sort
Sorts primitives of the collection.
Because sorting changes the indices (but not the feature IDs) of primitives in the collection, the function also returns an array mapping from previous index to new index. When sorting repeatedly, the array can be reused and passed as the 'result' argument for each call.
Return
Mapping from previous index to new index.