Sort a list of objects by a certain value within the object

Collections.sort(myList, new Comparator<EmployeeClass>(){
    public int compare(EmployeeClass obj1, EmployeeClass obj2) {
        // ## Ascending order
        return obj1.firstName.compareToIgnoreCase(obj2.firstName); // To compare string values
        // return Integer.valueOf(obj1.empId).compareTo(obj2.empId); // To compare integer values

        // ## Descending order
        // return obj2.firstName.compareToIgnoreCase(obj1.firstName); // To compare string values
        // return Integer.valueOf(obj2.empId).compareTo(obj1.empId); // To compare integer values
        }
    });
responseDto.getValues().sort((o1, o2) -> o1.getTime().compareTo(o2.getTime()));
responseDto.getValues().sort(Comparator.comparing(ItemTableResponseDto.Value::getTime));

References
https://stackoverflow.com/questions/9109890/android-java-how-to-sort-a-list-of-objects-by-a-certain-value-within-the-object