You are here: Lists > ListSorter

# ListSorter

Sorts the elements of the given list. The sorting can either be alphabetic or numeric, and in either ascending or descending order.

## Examples

If an input feature had these attributes:

somelist{0} = 3

somelist{1} = 17

somelist{2} = 4

somelist{3} = 9

somelist{4} = 2

and the list name is set to somelist{}, then the feature leaving the transformer will have these attributes:

somelist{0} = 2

somelist{1} = 3

somelist{2} = 4

somelist{3} = 9

somelist{4} = 17

Note that if there were other attributes in the list "parallel" to the attribute being operated on, these will also be moved in the list to stay in "parallel" with the key attribute.

For example, if the input feature had these attributes:

somelist{0}.kind = 'paved'

somelist{0}.count = 3

somelist{1}.kind = 'smooth'

somelist{1}.count = 17

somelist{2}.kind = 'trail'

somelist{2}.count = 4

somelist{3}.kind = 'rough'

somelist{3}.count = 9

somelist{4}.kind = 'logging'

somelist{4}.count = 2

and the list name is set to somelist{}.count, then the feature leaving the transformer will have these attributes:

somelist{0}.kind = 'logging'

somelist{0}.count = 2

somelist{1}.kind = 'paved'

somelist{1}.count = 3

somelist{2}.kind = 'trail'

somelist{2}.count = 4

somelist{3}.kind = 'rough'

somelist{3}.count = 9

somelist{4}.kind = 'smooth'

somelist{4}.count = 17

Lastly, if the original list was sparse, that is, it was missing some elements, the sorting operation will have the side effect of compacting the list to make all elements have consecutive indices. For example, if the input feature had these attributes:

somelist{0}.kind = 'paved'

somelist{0}.count = 3

somelist{3}.kind = 'rough'

somelist{3}.count = 9

somelist{4}.kind = 'logging'

somelist{4}.count = 2

and the list name is set to somelist{}.count, then the feature leaving the transformer will have these attributes:

somelist{0}.kind = 'logging'

somelist{0}.count = 2

somelist{1}.kind = 'paved'

somelist{1}.count = 3

somelist{3}.kind = 'rough'

somelist{3}.count = 9