1 package com.icl.saxon.sort; 2 3 6 12 13 public class LowercaseFirstComparer 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 30 while (true) { 31 if (i==alen && j==blen) break; 32 if (i==alen) return -1; 33 if (j==blen) return +1; 34 int diff = Character.toLowerCase(a1[i]) - 35 Character.toLowerCase(b1[j]); 36 i++; 37 j++; 38 if (diff!=0) return diff; 39 } 40 41 i = 0; 42 j = 0; 43 while (true) { 44 if (i==alen) return 0; 45 int diff = a1[i++] - b1[j++]; 46 if (diff!=0) { 47 return (Character.isLowerCase(a1[i-1]) ? -1 : +1); 48 } 49 } 50 51 } 52 53 54 } 55 | Popular Tags |