I have atoms of the following format in my knowledge base:
car_details(bmw, [1, 3, 5], 40000).
car_details(audi, [1, 3, 4, 5, 6, 8], 60000).
car_details(volvo, [40, 60, 80, 90], 50000).
car_details(mercedes, [a, b, c, e, s], 80000).
I am trying to sort these atoms based on their costs (3rd position values). Is there a built in predicate which can allow me to do that? I've tried using sort/2 with the findall predicate. However, that only results in a sorted list of all the costs. I want the associated information with it too.
The expected result from the above should be of the following format:
[[bmw, [1, 3, 5], 40000], [volvo, [40, 60, 80, 90], 50000], [audi, [1, 3, 4, 5, 6, 8], 60000], [mercedes, [a, b, c, e, s], 80000]].