X-Received: by 10.224.17.140 with SMTP id s12mr12921834qaa.3.1362244739503; Sat, 02 Mar 2013 09:18:59 -0800 (PST) X-Received: by 10.49.75.9 with SMTP id y9mr1626558qev.9.1362244739467; Sat, 02 Mar 2013 09:18:59 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!t2no6279034qal.0!news-out.google.com!q17ni7qal.0!nntp.google.com!dd2no4410227qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Sat, 2 Mar 2013 09:18:59 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=99.119.199.15; posting-account=spHjNgoAAAAlfnyJF7qz-h54hyM0w9rC NNTP-Posting-Host: 99.119.199.15 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Sorting (deeply) nested lists From: mamboknave@gmail.com Injection-Date: Sat, 02 Mar 2013 17:18:59 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.python:40338 I cannot resolve this on my own. Need help, please... nestedTuples = [ [ (L0t0e0, L0t0e1, L0t0e2), (L0t1e0, 2, L0t1e2), (L0t2e0, L0t2e1, L0t2e2) ], [ (L1t0e0, L1t0e1, L1t0e2), (L1t1e0, 0, L1t1e2), (L1t2e0, L1t2e1, L1t2e2) ], [ (L2t0e0, L2t0e1, L2t0e2), (L2t1e0, 1, L2t1e2), (L2t2e0, L2t2e1, L2t2e2) ] ] With LNtXeY I mean the element Y in the tuple X of the list N. How can I sort nestedTuples by, say, the 2nd element in the 2nd tuple of each list? The above should get sorted as : nestedTuples = [ [ (L1t0e0, L1t0e1, L1t0e2), (L1t1e0, 0, L1t1e2), (L1t2e0, L1t2e1, L1t2e2) ], [ (L2t0e0, L2t0e1, L2t0e2), (L2t1e0, 1, L2t1e2), (L2t2e0, L2t2e1, L2t2e2) ], [ (L0t0e0, L0t0e1, L0t0e2), (L0t1e0, 2, L0t1e2), (L0t2e0, L0t2e1, L0t2e2) ] ] Thanks so much!!