[portland] Meeting Tomorrow?
kirby urner
kirby.urner at gmail.com
Tue Mar 11 02:25:41 CET 2008
Yeah, hard to debug this way, I agree.
Note that if you're trying to do a sort within sort, you can do like
a database key (m, n), where m, n are your two fields.
def extract(row):
"""return (m,n) for sorting purposes"""
return (row[2],row[0])
>>> data = [
('pia', 'field1', 'scurve', 3, 4, 5),
('zaza', 'field1', 'bellcurve', 9, 8, 8),
('kirby', 'field1', 'bellcurve', 1, 2, 3),
('divine', 'field1', 'trapezoid', 1, 2, 3)]
>>> sorted(data, key = extract)
[('kirby', 'field1', 'bellcurve', 1, 2, 3),
('zaza', 'field1', 'bellcurve', 9, 8, 8),
('pia', 'field1', 'scurve', 3, 4, 5),
('divine', 'field1', 'trapezoid', 1, 2, 3)]
i.e. I'm sorting on field0 (proper name) *within* field 2 (test type).
Kirby
On Mon, Mar 10, 2008 at 4:55 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:
> On Mon, 10 Mar 2008, kirby urner wrote:
>
> > My personal advice, coder to coder, would be to implement a non-itertools
> > solution first, then go to itertools later if you feel there's a
> > significant advantage.
>
> Kirby,
>
> That's excellent advice. Unfortunately, I did not come up with working
> code before Dylan suggested the itertools approach.
>
> What I got was the first curve, then all the rest on a single set of axes.
> I had fits trying to find how to loop through all the tupples in the list,
> grouping each set by item[1].
>
> I don't care which approach is used, but I'm missing the python experience
> to get it working.
>
> Thanks,
>
>
>
> Rich
>
> --
> Richard B. Shepard, Ph.D. | Integrity Credibility
> Applied Ecosystem Services, Inc. | Innovation
> <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
> _______________________________________________
> Portland mailing list
> Portland at python.org
> http://mail.python.org/mailman/listinfo/portland
>
More information about the Portland
mailing list