En Fri, 04 Apr 2008 18:08:57 -0300, <[EMAIL PROTECTED]> escribió:

>> b) Define a function to extract a "key" from your items such that items  
>>  
>> compare the same as their keys. For example, key(x) -> x.lower() may be  
>>  
>> used to compare text case-insensitively.
>> Then, use a tuple (key, value) instead of the bare value. When  
>> extracting  
>> items from the queue, remember to unpack both parts. This is known as  
>> the  
>> decorate-sort-undecorate pattern; google for it.
>> This is the approach used on your code snippet.
>>
> I liked decorate-sort-undecorate pattern idea.
> But is there anyway I can provide information for tie breaking.
> so for case, where keyfunc(x) returns same values,
> I need to provide additional tie-breaking rules, is that possible to
> do?

Use as much elements in the tuple as you need. By example, you could have  
(year, month, amount, invoice_object) - you would get invocies sorted by  
year, then by month, then by amount.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to