How do I write a unit test to verify that a function sorts its result? [duplicate]
This question already has answers here : How to test the ordering of elements in a Collection in JUnit test? (4 answers) Closed 2 years ago . I have a data source from which I can request a list of people that live in a (any) country, and a method which retrieves the people from that data source and sorts them by their name alphabetically. How should I write my unit test to make sure that the sorting part of my method works properly? This is what my SUT looks like: class PeopleStuff { public IData data; public List<Person> getSortedPeopleForCountry(String countryName) { List<Person> people =