001 package railo.runtime.type.comparator; 002 003 import java.util.Comparator; 004 005 import railo.runtime.op.Caster; 006 import railo.runtime.type.Collection; 007 import railo.runtime.type.Collection.Key; 008 import railo.runtime.type.Struct; 009 010 public class ArrayOfStructComparator implements Comparator<Struct> { 011 012 013 private Key key; 014 015 /** 016 * Constructor of the class 017 * @param key key used from struct 018 */ 019 public ArrayOfStructComparator(Collection.Key key){ 020 this.key=key; 021 } 022 023 public int compare(Struct s1, Struct s2) { 024 return compareObjects(s1.get(key,""), s2.get(key,"")) ; 025 } 026 027 028 private int compareObjects(Object oLeft, Object oRight) { 029 return Caster.toString(oLeft,"").compareToIgnoreCase(Caster.toString(oRight,"")); 030 //return Caster.toString(oLeft).compareTo(Caster.toString(oRight)); 031 } 032 033 034 035 }