How to make compareTo sort a list alphabetically?

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-05-28T23:05:34Z Indexed on 2010/05/28 23:12 UTC
Read the original article Hit count: 142

Filed under:

Hi

How do I change my code so that it lists the elements in alphabetical order from a to z. Right now it's ordering from z to a. I can't figure it out and am stuck :-/

    String sName1 = ((Address)o).getSurname().toLowerCase();
    String sName2 = (this.surname).toLowerCase();
    int result = (sName1).compareTo(sName2);

    return result;

Thanks :)

© Stack Overflow or respective owner

Related posts about java