I have list of items that i need to sort by 2 parameters, first param is orderIndex, and i have that part working correctly (see bellow code), second param after orderIndex is amount. So basically first items should be ones with lowest order index, and they needs to be sorted by amount.
result.stream().sorted { s1, s2 -> s1.intervalType.orderIndex.compareTo(s2.intervalType.orderIndex) }.collect(Collectors.toList())
At this moment i have that code, and it is sorting just by orderIndex, second parameter amount is located at s1.item.amount.
Any idea how to upgrade this code with second ordering param ?
I have found this example
persons.stream().sorted(Comparator.comparing(Person::getName).thenComparing(Person::getAge));
my question here is, how to access other object in Person, for example in my case i have IntervalType object in object that i'm sorting, and i need to use intervalType.orderIndex
Note:
Just for note i need this in Kotlin not in Java.