how to find the longst element list of lists

Felipe Almeida Lessa felipe.lessa at gmail.com
Sun Jan 7 16:47:10 EST 2007


On 1/7/07, Michael M. <michael at mustun.ch> wrote:
> How to find the longst element list of lists?

s1 = ["q", "e", "d"]
s2 = ["a", "b"]
s3 = ["a", "b", "c", "d"]

s = [s1, s2, s3]
s.sort(key=len, reverse=True)
print s[0] is s3
print s[1] is s1
print s[2] is s2

sx1, sx2, sx3 = s
print 'sx1:', sx1
print 'sx2:', sx2
print 'sx3:', sx3

-- 
Felipe.



More information about the Python-list mailing list