sort functions in python

Jeff Schwab jeff at schwabcenter.com
Sun Feb 10 13:43:40 EST 2008


Steven D'Aprano wrote:
> On Sat, 09 Feb 2008 14:28:15 -0800, Jeff Schwab wrote:
> 
>> Steven D'Aprano wrote:
>>> On Sat, 09 Feb 2008 13:37:23 -0800, Jeff Schwab wrote:
>>>
>>>> Carl Banks wrote:
>>>>> On Feb 8, 10:09 pm, Jeff Schwab <j... at schwabcenter.com> wrote:
>>>>>> If you expect your data to be pretty nearly sorted already, but you
>>>>>> just want to make sure (e.g. because a small number of elements may
>>>>>> have been inserted or removed since the last sort), bubble-sort is a
>>>>>> good choice.
>>>>> But if you're at that stage you probably were doing something wrong
>>>>> in the first place.
>>>> How do you figure?  You don't always have control over the
>>>> insertions/replacements, or where they happen.  As a silly example,
>>>> assume you have a sorted list of children, by height.  Maybe you check
>>>> your list once per school semester.  The new sort order for any given
>>>> semester will likely be very close to the previous order; however, a
>>>> few
>>>>   swaps may be in order, according to the different speeds at which
>>>> children have grown.
>>> You check their heights once per semester, but you're worried about an
>>> extra ten or twenty microseconds to sort the data?
>> Are you serious?
>>
>> The fact that you wouldn't use a Python script for this is what makes it
>> a "silly" example in the first place.
> 
> 
> Okay, now you've broken my brain. Why on earth do you think Python isn't 
> suitable for processing a list of a few hundred, or even thousand, items?

Either you're joking, or we're definitely not getting anywhere.  I think 
we're through here.  See you else-thread.  No hard feelings.



More information about the Python-list mailing list