Skip to main content

Module sorting

Module sorting 

Source
Expand description

What decides which of two things comes first in a stream: music21’s sorting. music21’s sorting: the rules of its SortTuple, the six numbers that decide which of two things comes first in a stream.

The tuple itself is a Python class; what is here is what it decides that is not plain tuple order: how one compares against a bare offset, how two combine, and how one is written short.

Enums§

Comparison
A comparison of a sort tuple against a bare offset.

Constants§

SORT_TUPLE_FIELDS
The tuple’s fields, in music21’s order, which is the order they are compared in.

Functions§

at_end_compared
What a tuple stored at the end of its stream answers when compared against a bare offset: it stands after every offset but infinity, and equals infinity alone.
is_flag_field
Whether a field combines with another tuple’s by the larger of the two in add and the smaller in sub, as atEnd and isNotGrace do, rather than by adding or subtracting.
short_repr
A tuple written short, each part already written as Python writes it: 1.0 <0.20.323>, or End <4.7.[Grace].200> for a grace note stored at the end, whose offset is left out.