Re: [Tutor] sorting algorithm

2010-03-12 Thread Dave Angel
C.T. Matsumoto wrote: I've change the code and I think I have what you were talking about. def mysort(list_): for i in xrange(0, len(list_)): pos = i for j in xrange(pos+1, len(list_)): if list_[i] > list_[j]: pos = j list_[i]

Re: [Tutor] sorting algorithm

2010-03-12 Thread Jeff Johnson
Steven D'Aprano wrote: In future, could you please trim your quoting to be a little less excessive? There's no need to included the ENTIRE history of the thread in every post. That was about four pages of quoting to add five short sentences! Thank you. Will do. I usually do just didn't

Re: [Tutor] sorting algorithm

2010-03-12 Thread C.T. Matsumoto
I've change the code and I think I have what you were talking about. def mysort(list_): for i in xrange(0, len(list_)): pos = i for j in xrange(pos+1, len(list_)): if list_[i] > list_[j]: pos = j list_[i], lis

Re: [Tutor] sorting algorithm

2010-03-12 Thread Steven D'Aprano
On Fri, 12 Mar 2010 11:04:13 pm C.T. Matsumoto wrote: [snip 269 lines of quoted text] > Thanks Jeff. Indeed when I kept the code as is and added a doubled > element to the input list, it went into an infinite loop. For running > the swap it doesn't matter if the elements are equal. Catching equal

Re: [Tutor] sorting algorithm

2010-03-12 Thread C.T. Matsumoto
Dave Angel wrote: C.T. Matsumoto wrote: Dave Angel wrote: (You forgot to do a Reply-All, so your message went to just me, rather than to me and the list ) C.T. Matsumoto wrote: Dave Angel wrote: C.T. Matsumoto wrote: Hello, This is follow up on a question I had about algorithms. In the

Re: [Tutor] sorting algorithm

2010-03-12 Thread C.T. Matsumoto
Jeff Johnson wrote: C.T. Matsumoto wrote: Dave Angel wrote: (You forgot to do a Reply-All, so your message went to just me, rather than to me and the list ) C.T. Matsumoto wrote: Dave Angel wrote: C.T. Matsumoto wrote: Hello, This is follow up on a question I had about algorithms. In the

Re: [Tutor] sorting algorithm

2010-03-11 Thread Dave Angel
C.T. Matsumoto wrote: Dave Angel wrote: (You forgot to do a Reply-All, so your message went to just me, rather than to me and the list ) C.T. Matsumoto wrote: Dave Angel wrote: C.T. Matsumoto wrote: Hello, This is follow up on a question I had about algorithms. In the thread it was sugge

Re: [Tutor] sorting algorithm

2010-03-11 Thread Jeff Johnson
C.T. Matsumoto wrote: Dave Angel wrote: (You forgot to do a Reply-All, so your message went to just me, rather than to me and the list ) C.T. Matsumoto wrote: Dave Angel wrote: C.T. Matsumoto wrote: Hello, This is follow up on a question I had about algorithms. In the thread it was sugge

Re: [Tutor] sorting algorithm

2010-03-11 Thread C.T. Matsumoto
Dave Angel wrote: (You forgot to do a Reply-All, so your message went to just me, rather than to me and the list ) C.T. Matsumoto wrote: Dave Angel wrote: C.T. Matsumoto wrote: Hello, This is follow up on a question I had about algorithms. In the thread it was suggested I make my own sort

Re: [Tutor] sorting algorithm

2010-03-03 Thread Steven D'Aprano
On Thu, 4 Mar 2010 04:34:09 am Glen Zangirolami wrote: > http://www.sorting-algorithms.com/ > > It is a fantastic website that explains each kind of sort and how it > works. They also show you visuals how the sorts work and how fast > they go based on the amount of data. For actual practical work,

Re: [Tutor] sorting algorithm

2010-03-03 Thread Dave Angel
(You forgot to do a Reply-All, so your message went to just me, rather than to me and the list ) C.T. Matsumoto wrote: Dave Angel wrote: C.T. Matsumoto wrote: Hello, This is follow up on a question I had about algorithms. In the thread it was suggested I make my own sorting algorithm. He

Re: [Tutor] sorting algorithm

2010-03-03 Thread C.T. Matsumoto
Dave Angel wrote: C.T. Matsumoto wrote: Hello, This is follow up on a question I had about algorithms. In the thread it was suggested I make my own sorting algorithm. Here are my results. #!/usr/bin/python def sort_(list_): for item1 in list_: pos1 = list_.index(item1) pos

Re: [Tutor] sorting algorithm

2010-03-03 Thread Glen Zangirolami
http://www.sorting-algorithms.com/ It is a fantastic website that explains each kind of sort and how it works. They also show you visuals how the sorts work and how fast they go based on the amount of data. Depending on the amount/kind of data I would choose a sorting algorithm that fits your nee

Re: [Tutor] sorting algorithm

2010-03-03 Thread Dave Angel
C.T. Matsumoto wrote: Hello, This is follow up on a question I had about algorithms. In the thread it was suggested I make my own sorting algorithm. Here are my results. #!/usr/bin/python def sort_(list_): for item1 in list_: pos1 = list_.index(item1) pos2 = pos1 + 1

[Tutor] sorting algorithm

2010-03-03 Thread C.T. Matsumoto
Hello, This is follow up on a question I had about algorithms. In the thread it was suggested I make my own sorting algorithm. Here are my results. #!/usr/bin/python def sort_(list_): for item1 in list_: pos1 = list_.index(item1) pos2 = pos1 + 1 try: item2