I do have a enum class in kotlin in which I have to sort them differently based on a input parameters.
As of now, I have this class defined
enum class ProductItem constructor( val color, val price, val position ){ SHOES("red", "$", 2) CAR("blue", "$$$$$", 1) BOAT("green", "$$$$$$$$$$$$$", 3) } As of now using a simplify code like this:
it.sortedBy { it.ProductItem?.position }) I was expecting that the list of enum returned will be sorted in ascending order and show: CAR, SHOES and BOAT but it still shows SHOES, CAR, BOAT. It looks like the params position is not took into account. Any idea how to use the params position to sort the list of enum
Thanks
State = CAvsState = LO)? And how do these state values relate to the enum values?it.ProductItem?.positiondoes... Is ProductItem here a property? Can you please provide a main function that demonstrates the problem. (Also your enum code does not compile.)