Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] sorting Hashtbl.t
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alexander V.Voinov <avv@q...>
Subject: Re: [Caml-list] sorting Hashtbl.t

From: John Max Skaller <>
Subject: Re: [Caml-list] sorting Hashtbl.t
Date: Thu, 15 Aug 2002 08:16:47 +1000

> > 
> > 	From an algorithmic point of view, there is no way to sort an
> > hash table since there is no order attached to items. 
> Ocaml has a polymorphic comparison function (which works
> on all non-cyclic data structures). Therefore, any collection
> of (non-cyclic) data elements can be sorted, and the request
> actually makes sense. It is also something I wish to do
> often.
> However, I would ask for different function(s):
> 	Hastbl.to_list
> 	Hashtbl.to_lista
> 	Hashtbl.to_sorted_list compar
> 	Hashtbl.to_sorted_lista compar

I second this.

I've already defined something similar in a recent application, actually
equivalents of Python's .keys(), .values() and .items() with a subsequent sort
but I'd be happy with this interface as well.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: