I implemented a little "tri a bulles" algorithm (""bubble ordering"") like this:
(not very fast nor readable, but it works)
// List ordering
n = list_len(my_list);
for (i = 0; i < n; i++)
for (j = 0; j < n - i - 1; j++)
{
if (octstr_compare(list_get(my_list, j), list_get(my_list, j + 1)) > 0)
{
list_insert(my_list, j, list_get(my_list, j + 1));
list_delete(my_list, j + 2, 1);
}
}
-----Message d'origine-----
De : Stipe Tolj [mailto:[EMAIL PROTECTED]
Envoy� : mardi 29 juillet 2003 16:53
� : CHARBONNIER Christophe
Cc : [EMAIL PROTECTED]
Objet : Re: Get ordered dict keys
> Is there a (simple) way to get the keys of a Dict structure in an
> ordered manner ??
that's the major problem with simple hash tables, they are not ordered in terms of
their contents and the keys that are defined.
To obtain this you would have to implement overhead binary tree structures to the hash
to provide a feasable search and ordering on the structure.
I don't think you can have a simple way in obtaining the key in an ordered way from a
Dict. (please don't flame me if I'm wrong ;)
Stipe
[EMAIL PROTECTED]
-------------------------------------------------------------------
Wapme Systems AG
Vogelsanger Weg 80
40470 D�sseldorf
Tel: +49-211-74845-0
Fax: +49-211-74845-299
E-Mail: [EMAIL PROTECTED]
Internet: http://www.wapme-systems.de
-------------------------------------------------------------------
wapme.net - wherever you are