Sorting Strings in Java like Spreadsheet Column Names

Need to sort strings like the column names of spreadsheet applications? Meaning you want to sort strings in this fashion:

[, A, C, Z, A1, A2, AA, BA, DZ, BAD]

Here is a simple Java class to do so:

public class ExcelColumnName implements Comparable<ExcelColumnName> {

    public String columnName;

    public ExcelColumnName(String columnName) {
        this.columnName = columnName;
    }

    @Override
    public int compareTo(ExcelColumnName o) {
        if (this.columnName.length() > o.columnName.length()) {
            return 1;
        }
        if (this.columnName.length() < o.columnName.length()) {
            return -1;
        }
        return this.columnName.compareTo(o.columnName);
    }

    @Override
    public String toString() {
        return columnName;
    }
}

Page 1 of 1, totaling 1 entries