1 package com.icl.saxon.sort; 2 3 6 12 13 public class UppercaseFirstComparer extends Comparer { 14 15 21 22 public int compare(Object a, Object b) { 23 char[] a1 = ((String )a).toCharArray(); 24 char[] b1 = ((String )b).toCharArray(); 25 int alen = a1.length; 26 int blen = b1.length; 27 int i = 0; 28 int j = 0; 29 while (true) { 30 if (i==alen && j==blen) break; 31 if (i==alen) return -1; 32 if (j==blen) return +1; 33 int diff = Character.toLowerCase(a1[i++]) - Character.toLowerCase(b1[j++]); 34 if (diff!=0) return diff; 35 } 36 i = 0; 37 j = 0; 38 while (true) { 39 if (i==alen) return 0; 40 int diff = a1[i++] - b1[j++]; 41 if (diff!=0) { 42 return (Character.isUpperCase(a1[i-1]) ? -1 : +1); 43 } 44 } 45 46 } 47 48 } 49 | Popular Tags |