Added sorted, to bring these consistent with their scala equivalent, however this is inefficient and should be left to end user to sort or not.