« Return to Thread: How to sort list of sublists as per key/keys of sublist?

How to sort list of sublists as per key/keys of sublist?

by Lev777 :: Rate this Message:

Reply to Author | View in Thread

I have the following structure:

object('obj1', [id='12', color='blue']).
object('obj4', [id='13', color='red', weight=120]).
object('obj21', [id='15 a', color='yellow', weight=1000, price=23]).
object('obj21', [id='16 a', color='blue', weight=200, price=230]).

I have a predicate which finds all objects with particular key, e.g. objects with color='blue'.
In many cases result will be list of objects.
My question is:
How to write a sorting predicate which will sort objects within a resulting list by one of one or many  keys(id or/and price, etc...)

Thanks! 

 « Return to Thread: How to sort list of sublists as per key/keys of sublist?