Add sort function to order results in the API
Use metric to sort