List searchObjects(String query, String returnAttrs[], final String sortAttr, final boolean sortAscending, String base, int flags) throws ServiceException { final List result = new ArrayList();
List<NamedEntry> searchObjects(String query, String returnAttrs[], final String sortAttr, final boolean sortAscending, String base, int flags) throws ServiceException { final List<NamedEntry> result = new ArrayList<NamedEntry>();
    List searchObjects(String query, String returnAttrs[], final String sortAttr, final boolean sortAscending, String base, int flags)          throws ServiceException    {        final List result = new ArrayList();                NamedEntry.Visitor visitor = new NamedEntry.Visitor() {            public void visit(com.zimbra.cs.account.NamedEntry entry) throws ServiceException {                result.add(entry);            }        };                searchObjects(query, returnAttrs, base, flags, visitor);        final boolean byName = sortAttr == null || sortAttr.equals("name");         Comparator comparator = new Comparator() {            public int compare(Object oa, Object ob) {                LdapNamedEntry a = (LdapNamedEntry) oa;                LdapNamedEntry b = (LdapNamedEntry) ob;                int result = 0;                if (byName)                    result = a.getName().compareToIgnoreCase(b.getName());                else {                    String sa = a.getAttr(sortAttr);                    String sb = b.getAttr(sortAttr);                    if (sa == null) sa = "";                    if (sb == null) sb = "";                    result = sa.compareToIgnoreCase(sb);                }                return sortAscending ? result : -result;            }        };        Collections.sort(result, comparator);                return result;    }