Set functionLimits = new HashSet();
Comparator displayOrderComparator = new Comparator() { public int compare(Object o1, Object o2) { return ((Limit)o1).getDisplayOrder() - ((Limit)o2).getDisplayOrder(); } };  SortedSet functionLimits = new TreeSet(displayOrderComparator);
  public Limit[] getLimitsArray()  {    Set functionLimits = new HashSet();    Set permissions = this.getPermissions();    Iterator permissionsIterator = permissions.iterator();        while (permissionsIterator.hasNext())    {      Permission permission = (Permission)(permissionsIterator.next());      Set permissionLimits = ((PermissionImpl)permission).getLimits();      functionLimits.addAll(permissionLimits);    }    Limit[] limitsArray = new Limit[0];    return (Limit[])(functionLimits.toArray(limitsArray));  }