Skip to content

Instantly share code, notes, and snippets.

@0x0L
Created July 16, 2025 17:36
Show Gist options
  • Select an option

  • Save 0x0L/99de7e12e85ba1ea82f7058e6c73aa85 to your computer and use it in GitHub Desktop.

Select an option

Save 0x0L/99de7e12e85ba1ea82f7058e6c73aa85 to your computer and use it in GitHub Desktop.
Sort arrow dictionary arrays
import pyarrow as pa
import pyarrow.compute as pc
def sort_dictionary(arr):
o = pc.sort_indices(arr.dictionary)
return pa.DictionaryArray.from_arrays(
dictionary=pc.take(arr.dictionary, o),
indices=pc.take(pc.sort_indices(o), arr.indices)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment