idsortingalgorithm

This module contains the following classes:

  • IDSortingAlgorithm, enumerating and implementing the available algorithms to sort a list of XML id attributes.

Warning

This module is likely to be refactored in a future version

class aeneas.idsortingalgorithm.IDSortingAlgorithm(algorithm, rconf=None, logger=None)[source]

Enumeration of the available algorithms to sort a list of XML id attributes.

Parameters:
Raises:

ValueError: if the value of algorithm is not allowed

ALLOWED_VALUES = ['lexicographic', 'numeric', 'unsorted']

List of all the allowed values

LEXICOGRAPHIC = 'lexicographic'

Lexicographic sorting (e.g., f020 before f10 before f2)

NUMERIC = 'numeric'

Numeric sorting, ignoring any non-digit characters or leading zeroes (e.g., f2 (= 2) before f10 (= 10) before f020 (= 20))

UNSORTED = 'unsorted'

Do not sort and return the list of identifiers, in their original order (e.g., f2 before f020 before f10, assuming this was their order in the XML DOM)

sort(ids)[source]

Sort the given list of identifiers, returning a new (sorted) list.

Parameters:ids (list) – the list of identifiers to be sorted
Return type:list