Reference ABCMolecule ABCMolecule.sort
ABCMolecule.sort
sort(sort_method, ascending=True, inplace=False)
Sort the atoms by position, species, alphabetical or atomic number.
Parameters:
-
sort_method
(str | list[str] | list[list[str]]
) –Method given by which the atoms will be sorted.
- if sort_method is 'x' the atoms will be sorted by their x coordinate. - if sort_method is 'y' the atoms will be sorted by their y coordinate. - if sort_method is 'z' the atoms will be sorted by their z coordinate. - if sort_method is 'alphabetical' the atoms will be sorted in alphabetical order by their species. - if sort_method is 'periodical' the atoms will be sorted by their atomic number.
You can also supply a list of lists with position 0 being species and position 1 being 'x','y','z', or None.
This will sort the coordinates by species then by the method provided for each species, you can also add a list of bool for ascending values that will correspond to each species chosen method.
You can also supply a list of species and it will be reordered to the given order.
-
ascending
(bool or list of bool
, default:True
) –Sort ascending vs. descending. Specify list for multiple sort orders (as described above). If this is a list of bools, must match the length of sort_method.
-
inplace
(bool
, default:False
) –If True, perform operation in-place.
Returns:
-
ABCMolecule
–ABCMolecule object with all atoms resorted.