Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
On Feb 6, 2:41 pm, Stephen Hansen wrote: > > I think there may have been a misunderstanding.  I was already using > > attrgetter, my problem is that it doesn't appear to be sorting by the > > argument i give it.  How does sort work with strings?  How about with > > datetime.time or datetime.date?

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Stephen Hansen
> I think there may have been a misunderstanding. I was already using > attrgetter, my problem is that it doesn't appear to be sorting by the > argument i give it. How does sort work with strings? How about with > datetime.time or datetime.date? You were using the attrgetter, but it looks like

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
On Feb 6, 2:34 pm, Robocop wrote: > On Feb 6, 2:20 pm, Robocop wrote: > > > > > On Feb 6, 2:17 pm, Robocop wrote: > > > > On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote: > > > > > Robocop: > > > > > >then within each department block of the list, have it organized by > > > > >projects.< > >

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Terry Reedy
Robocop wrote: UH OH GUYS! line 110, in sorter timesheets.sort(key=attrgetter("department", "engagement", "date","start")) TypeError: attrgetter expected 1 arguments, got 4 Um... what version of Python are you running? Alway specify. (Too many people do not). In 3.0 from operator imp

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
On Feb 6, 2:20 pm, Robocop wrote: > On Feb 6, 2:17 pm, Robocop wrote: > > > > > On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote: > > > > Robocop: > > > > >then within each department block of the list, have it organized by > > > >projects.< > > > > I don't know what does it means. > > > > > ti

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
On Feb 6, 2:17 pm, Robocop wrote: > On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote: > > > > > Robocop: > > > >then within each department block of the list, have it organized by > > >projects.< > > > I don't know what does it means. > > > > timesheets.sort(key=operator.attrgetter('string')) >

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote: > Robocop: > > >then within each department block of the list, have it organized by > >projects.< > > I don't know what does it means. > > > timesheets.sort(key=operator.attrgetter('string')) > > Try something like: > timesheets.sort(key=attrgette

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote: > Robocop: > > >then within each department block of the list, have it organized by > >projects.< > > I don't know what does it means. > > > timesheets.sort(key=operator.attrgetter('string')) > > Try something like: > timesheets.sort(key=attrgette

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread bearophileHUGS
Robocop: >then within each department block of the list, have it organized by projects.< I don't know what does it means. > timesheets.sort(key=operator.attrgetter('string')) Try something like: timesheets.sort(key=attrgetter("department", "engagement", "date", "stare_hour")) > My brain might

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Miki
> I've found myself stumped when trying to organize this list of > objects.  The objects in question are timesheets which i'd like to > sort by four attributes: > > class TimeSheet: >   department = string >   engagement = string >   date = datetime.date >   stare_hour = datetime.time > > My ultim

Trouble sorting a list of objects by attributes

2009-02-06 Thread rdmurray
Quoth Robocop : > Hello again, > I've found myself stumped when trying to organize this list of > objects. The objects in question are timesheets which i'd like to > sort by four attributes: > > class TimeSheet: > department = string > engagement = string > date = datetime.date > stare_ho

Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
Hello again, I've found myself stumped when trying to organize this list of objects. The objects in question are timesheets which i'd like to sort by four attributes: class TimeSheet: department = string engagement = string date = datetime.date stare_hour = datetime.time My ultimate goal