Sorted list of agents within a population

When doing some actions with agents of some population, you may need to sort them by some value. There is no need in rearranging agents within a population, you can use the following AnyLogic functions to get the ordered list, and then work with it in your code.

<T> java.util.List<T> sortAscending(population, value) - Returns a new list with rearranged agents from the given population sorted ascending by value.

<T> java.util.List<T> sortDescending(population, value) - Returns a new list with rearranged agents from the given population sorted descending by value.

Examples: 

  List sortedByAgeAsc = sortAscending( people, p -> p.age ));

  List sortedByIncomeDesc = sortDescending( people, p -> p.income ));