Zhang Huangbin wrote: > Michael Ströder wrote: >> 100+ entries are not so many. So you could try sorting the list of >> search results retrieved with LDAPObject.ldap_search_ext_s() by invoking >> list method .sort(). Make sure you understand how to control the >> comparisons. >> >> See item 8. here: >> http://docs.python.org/library/stdtypes.html#index-591 >> > > No idea yet. Any example?
Bear in mind search results returned by synchronous search methods are in a list of 2-tuples each consisting of the DN string and the entry dictionary like this: [(dn,entry)] Without testing just as food for thought: Compare function for case-insensitive comparison of the DN: cmp=lambda x,y: cmp(x[0].lower(), y[0}.lower()) Compare function for case-insensitive comparison of the first attribute value of 'cn' (this would choke with KeyError exception if there's no attribute 'cn' in the entry): cmp=lambda x,y: cmp(x[1]['cn'][0].lower(), y[1]['cn'][0].lower()) And then results.sort(cmp). I don't know how fast this is though. The rest of the homework is up to you. For various list sorting aspects you should ask in news:comp.lang.python Ciao, Michael. ------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com _______________________________________________ Python-LDAP-dev mailing list Python-LDAP-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/python-ldap-dev