sort_paths

sort_paths(path_list, sorting_key='cycles')[source]

Sorts the given paths according to a sorting keyword.

The paths must have the following structure: /xx/xx…/[NUMBER][SORTING_KEY].* E.g. test_3cycles_force1.png. This will extract the number 3 from the filename and sort other similar filenames in ascending order.

Parameters
path_list: list

list of strings of the image names

sorting_key: str

A sorting keyword. The number for sorting must be before the keyword. E.g. “cycles” will sort all paths with [NUMBER]cycles.* e.g. 123cycles, 234cycles,.. etc

Returns
paths: array

Sorted paths in ascending order

numbers: array

The numbers from the match corresponding to the paths.

Examples

>>> paths = ['A_1cycles.jpg', 'A_50cycles.jpg', 'A_2cycles.jpg', 'A_test.jpg']
>>> sort_paths(paths, 'cycles')
(array(['A_1cycles.jpg', 'A_2cycles.jpg', 'A_50cycles.jpg']), array([ 1,  2, 50]))