Use bisect : bisect « Data Structure « Python






Use bisect

Use bisect

import bisect

scores = [(100, 'perl'), (200, 'tcl'), (400, 'lua'), (500, 'python')]
bisect.insort(scores, (300, 'ruby'))
print scores




           
       








Related examples in the same category