[api] allow a property and sorting function to be passed to the sorted function