That will sort whatever is inside of lActions base on the anonymous comparator object. Check here for details on the Comparator interface, http://java.sun.com/j2se/1.4/docs/api/java/util/Comparator.html
> -----Original Message----- > From: Simon Kelly [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 17, 2003 4:22 AM > To: Struts Users Mailing List > Subject: [OT]: I don't see how this works? > > > I'm just scanning thru the struts source, looking for > ModuleConfig stuff and > ran over this bit of code. > > I've never seen anything written like it and wondered what > it's doing and > how the hell does it work? > > Cheers > > Simon > > <CODE> > Collections.sort(lActions, new Comparator() { > public int compare(Object o1, Object o2) { > ValidatorAction va1 = (ValidatorAction) o1; > ValidatorAction va2 = (ValidatorAction) o2; > if ((va1.getDepends() == null || va1.getDepends().length() == 0) > && (va2.getDepends() == null || va2.getDepends().length() == 0)) { > return 0; > } else if ( > (va1.getDepends() != null && va1.getDepends().length() > 0) > && (va2.getDepends() == null || va2.getDepends().length() == 0)) { > return 1; > } else if ( > (va1.getDepends() == null || va1.getDepends().length() == 0) > && (va2.getDepends() != null && va2.getDepends().length() > 0)) { > return -1; > } else { > return va1.getDependencies().size() - va2.getDependencies().size(); > } > } > }); > Institut fuer > Prozessdatenverarbeitung > und Elektronik, > Forschungszentrum Karlsruhe GmbH, > Postfach 3640, > D-76021 Karlsruhe, > Germany. > > Tel: (+49)/7247 82-4042 > E-mail : [EMAIL PROTECTED] > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

