Making Java Objects Comparable
Subject:   Regarding sorting of objects
Date:   2006-11-28 23:26:24
From:   raoul.schmidiger
Response to: Regarding sorting of objects

Delegate the compareTo to Strings implementation:

public int compareTo(Object o) {
return this.getText().compareTo(o.getText());

Regards Raoul

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Regarding sorting of objects
    2006-11-29 01:14:09  raoul.schmidiger [View]

    for sorting with 2 criterias, you will have to first sort by one criteria and then within each "element" do a second sort with the other criteria.

    sort1: 1, 2, 3 ... n
    sort2 1: a, b, c ..., z
    sort2 2: a, b, c ..., z
    sort2 3: a, b, c ..., z
    sort2 ...: a, b, c ..., z
    sort2 n: a, b, c ..., z