sandro.tosi at gmail.com
Wed Feb 16 23:49:26 CET 2011
thanks for your email
On Wed, Feb 9, 2011 at 22:02, Erden Oktay <oktay_erden at wheatonma.edu> wrote:
>> import bisect
>>>> scores = [(100, 'perl'), (200, 'tcl'), (400, 'lua'), (500, 'python')]
>>>> bisect.insort(scores, (300, 'ruby'))
> [(100, 'perl'), (200, 'tcl'), (300, 'ruby'), (400, 'lua'), (500, 'python')]
> I thought instead of insort you meant insert.
I see why you think it's a typo, but bisect module has a 'insort()'
method for real :) it inserts an element in an already sorted
sequence, keeping it sorted. you can refer for a more detailed
description to the online doc.
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi
More information about the docs