https://kotlinlang.org logo
Title
u

user

07/11/2022, 9:31 AM
Filter a list of transactions I have lists of transactions, I would like if the list contains 4 transactions, delete the two lowest, if the list contains 5 transactions, always the 2 cheapest, if there are 6, the 3 cheapest and so on. allDrivers.map { driver -> val transacsByDriver = allTransacs.filter { transaction -> transaction.driver?.userId == driver.userId } val tt = transacsByDriver.filterIndexed { index, transaction -> Math.floorDiv(index, 2) == index.floorDiv(2)} println(tt)...