All pastes #977483 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-04-08 21:24 UTC
rendered paste body
int compare(Object a, Object b)
{
  char[] c1 = a.toString().toCharArray();
  char[] c2 = b.toString().toCharArray();
  ArrayUtils.reverse(c1);
  ArrayUtils.reverse(c2);
		
  return new String(c1).compareTo(new String(c2));
}

//
// ArrayUtils.java
//
public static void reverse<T>(T[] arr) {
   int left  = 0;          // index of leftmost element
   int right = b.length-1; // index of rightmost element
  
   T temp;
   while (left < right) 
   {
      temp = arr[left]; 
      arr[left]  = arr[right]; 
      arr[right] = temp;
     
      left++;
      right--;
   }
}