Quote:
Originally Posted by rajeshnaidu
I had done using Comparable and Comparator interfaces. But the problem here is need to handle both ascending and descending dynamically based on parameter passed.
|
what did you do? the scenario you describe can be pretty easily accomplished using just comparator...(its usually easier to sort it ascending and reverse the results for descending >).. )
Quote:
Originally Posted by ctbalamurali
Dynamic variable can be passed to determine the the sorting order
Please find the updated sample code.
PHP Code:
package Sorting;
public class Student implements Comparable { public Long student_id; public String last_name; public String first_name; public boolean isAsc; ...
}
|
cmon...this isn't passing a dynamic variable :O...have you considered the case when an collection containing some students who want to be sorted ascending and others descending !!