Re: Problem with the sort() function

2005-02-23 Thread clementine
Thanks everyone!!:-) Nicks solution coupled with John's modifications worked great for 2.2!! Yipeee...!!:):) -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with the sort() function

2005-02-22 Thread John Machin
clementine wrote: > Thanx Nick...I forgot to mention im using python 2.2 and along with a host > of other things it doesnt seem to have the enumarate built in function > :(:(:(...is it possible to replace it by something else? I dont think > simulating it will be feasible Faced with Nick's on

Re: Problem with the sort() function

2005-02-22 Thread Steven Bethard
Scott David Daniels wrote: or even (if you can't be bothered to look up when features happened): try: test = enumerate except NameError: def enumerate(iterable): ... try: test = sorted except NameError: def sorted(iterable, cmp=None, key=N

Re: Problem with the sort() function

2005-02-22 Thread Steven Bethard
Fuzzyman wrote: Iterators are available in python 2.2 class enumerate: def __init__(self, inlist): self.inlist = inlist self.index = 0 def next(self): if self.index >= len(self.inlist): raise StopIteration thisone = self.inlist[self.index] self.index

Re: Problem with the sort() function

2005-02-22 Thread Duncan Booth
Scott David Daniels wrote: > if sys.version_info < (2, 4): > def sorted(iterable, cmp=None, key=None, reverse=False): > "return a sorted copy of its input" > seq = list(iterable) > if reverse: > seq.reverse()# preserve s

Re: Problem with the sort() function

2005-02-22 Thread Scott David Daniels
Nick Coghlan wrote: def mysort(iterable, cmp=None, key=None, reverse=False): "return a sorted copy of its input" if sys.version_info >= (2,4): return sorted(iterable, cmp, key, reverse) seq = list(iterable) if reverse: seq.reverse()# preserve stability if

Re: Problem with the sort() function

2005-02-22 Thread Fuzzyman
Sion Arrowsmith wrote: > clementine <[EMAIL PROTECTED]> wrote: > >Thanx Nick...I forgot to mention im using python 2.2 and along with a host > >of other things it doesnt seem to have the enumarate built in function > >:(:(:(...is it possible to replace it by something else? I dont think > >simulat

Re: Problem with the sort() function

2005-02-22 Thread Sion Arrowsmith
clementine <[EMAIL PROTECTED]> wrote: >Thanx Nick...I forgot to mention im using python 2.2 and along with a host >of other things it doesnt seem to have the enumarate built in function >:(:(:(...is it possible to replace it by something else? I dont think >simulating it will be feasible Here'

Re: Problem with the sort() function

2005-02-22 Thread clementine
Thanx Nick...I forgot to mention im using python 2.2 and along with a host of other things it doesnt seem to have the enumarate built in function :(:(:(...is it possible to replace it by something else? I dont think simulating it will be feasible -- http://mail.python.org/mailman/listinfo/pyt

Re: Problem with the sort() function

2005-02-22 Thread Nick Coghlan
clementine wrote: Hi, I have an array of arrays in the form of list = [[3,'fork',0.3,1],[2,'fork,0.1,2],[3,'exec',0.2,2]] The in-built sort(),list.sort() sorts on the first element, if the first elts are equal then it sorts on the second elt and so on...But i really dont want to search on the sec

Problem with the sort() function

2005-02-21 Thread clementine
Hi, I have an array of arrays in the form of list = [[3,'fork',0.3,1],[2,'fork,0.1,2],[3,'exec',0.2,2]] The in-built sort(),list.sort() sorts on the first element, if the first elts are equal then it sorts on the second elt and so on...But i really dont want to search on the second elt if the fi