lists - append - unique and sorted

Dan Bishop danb_83 at yahoo.com
Wed Jun 6 22:01:50 EDT 2007


On Jun 6, 10:26 am, rhXX <rh00... at gmail.com> wrote:
> hi,
>
> can i append a item to a list using criterias:
>
> - UNIQUE - if there already exist don't append
>
> and/or
>
> - SORTED - INSERT in the correct place using some criteria?
>
> tks in advance

If you don't need the list to be sorted until you're done building it,
you can just use:

lst = sorted(set(lst))




More information about the Python-list mailing list