quantlab.utils.symbol_axis.sort_symbol_axis#
- quantlab.utils.symbol_axis.sort_symbol_axis(values)[source]#
Sort a symbol axis, numerically when every label is integral.
Security identifiers such as PERMNOs are integers that are sometimes carried as digit strings; plain
sorted()on the text would put"14593"before"7000". When every label passes_is_integralthe sort key isint; a mixed or non-integer axis falls back tostrcomparison rather than raising, because this function orders labels and does not validate them.Only the order changes. Elements keep their input type, so digit strings come back as digit strings; converting them is
normalize_to_axis_dtype’s job.- Parameters:
- valuesIterable
The labels to sort.
- Returns:
- list
A new sorted list, empty for empty input.
Examples
>>> sort_symbol_axis(["10107", "14593", "7000"]) ['7000', '10107', '14593']