Back to main menu

## Option: sort

#### Syntax

`-sort <property> <order>`

`-sort random`

#### Description

This option sorts atoms according to one of their properties.

The parameters for this option are:

- property: atom property to be sorted; can be one of 'species' (or 's'), 'x', 'y', 'z', or any per-atom auxiliary property (read from the input file or defined with the option `-properties`);
- order: if 'up' or 'down' the property is sorted by increasing or decreasing values, respectively. If 'pack', identical values of the property is packed so that they are contiguous (but without sorting them by increasing or decreasing values). If 'reverse', then the order of atoms is reversed.

If the option is called as "-sort random", then the list of atoms is shuffled in random order.

This option does not transform the system or move atoms. It changes the index of atoms, i.e. the order in which they appear in the final file. For example, after applying this option, the atom #i of chemical symbol Xx at position (x,y,z) and with auxiliary properties of values A1, A2, etc., will still be of the same chemical species, be at the same position, and have the same values of its auxiliary properties, but it will have a different index #j.

#### Default

By default atoms are not rearranged at all.

#### Examples

- `atomsk initial.cfg -sort species up final.xyz`

  This will rearrange the order in which atoms are written, sorting them by increasing value of their atomic weigth.

- `atomsk initial.cfg -sort z down final.xyz`

  This will sort atoms by decreasing values of their Z coordinate.

- `atomsk initial.cfg -sort s pack POSCAR`

  This will pack atoms that have the same atomic number so that they are contiguous.

- `atomsk initial.lmc -sort vx up final.xyz exyz`

  This will read the file `initial.lmc` and sort atoms by increasing values of their velocity along X. These data will then be written to the file `final.xyz` in extended XYZ format.

- `atomsk initial.lmc -sort random final.cfg`

  This will randomize the list of atoms, i.e. the index of all atoms will change so that they appear in a completely random order.

Back to main menu