Example usage for java.util Comparator interface-usage

List of usage examples for java.util Comparator interface-usage

Introduction

In this page you can find the example usage for java.util Comparator interface-usage.

Usage

From source file CompTypeComparator.java

class CompTypeComparator implements Comparator {
    public int compare(Object o1, Object o2) {
        int j1 = ((Integer) o1);
        int j2 = ((Integer) o2);
        return (j1 < j2 ? -1 : (j1 == j2 ? 0 : 1));
    }

From source file Compare2DArray.java

class Compare2DArray implements Comparator {
    public int compare(Object a, Object b) {
        int aa[] = (int[]) a;
        int bb[] = (int[]) b;
        for (int i = 0; i < aa.length && i < bb.length; i++)
            if (aa[i] != bb[i])

From source file MyComparator.java

class MyComparator implements Comparator<String> {
    public int compare(String a, String b) {
        String aStr, bStr;
        aStr = a;
        bStr = b;
        return bStr.compareTo(aStr);

From source file MyComparator.java

class MyComparator implements Comparator<String> {
    public int compare(String strA, String strB) {
        return strA.compareToIgnoreCase(strB);
    }
}

From source file MyComparator.java

class MyComparator implements Comparator<String> {

    public int compare(String strA, String strB) {
        return strB.compareTo(strA);
    }
}

From source file IgnoreCaseComp.java

class IgnoreCaseComp implements Comparator<String> {
    Collator col;

    IgnoreCaseComp() {
        col = Collator.getInstance();

From source file MyComp.java

class MyComp implements Comparator<String> {
    public int compare(String a, String b) {
        return b.compareTo(a);
    }
}

From source file MyComparator.java

class MyComparator implements Comparator<String> {
    public int compare(String a, String b) {
        String aStr, bStr;

        aStr = a;
        bStr = b;

From source file MyComparator.java

class MyComparator implements Comparator<String> {
    public int compare(String a, String b) {
        return new Integer(a.length()).compareTo(b.length());
    }
}

From source file TComp.java

class TComp implements Comparator<String> {
    public int compare(String a, String b) {
        int i, j, k;
        String aStr, bStr;

        aStr = a;