From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA23856; Thu, 15 Aug 2002 01:25:16 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA24050 for ; Thu, 15 Aug 2002 01:25:15 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from str12.sobor.org (adsl-63-198-183-99.dsl.snfc21.pacbell.net [63.198.183.99]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g7ENPDD25058 for ; Thu, 15 Aug 2002 01:25:14 +0200 (MET DST) Received: from localhost (localhost.localdomain [127.0.0.1]) by str12.sobor.org (Postfix) with ESMTP id DD56199860; Wed, 14 Aug 2002 16:13:59 -0700 (PDT) Date: Wed, 14 Aug 2002 16:13:59 -0700 (PDT) Message-Id: <20020814.161359.74730204.avv@quasar.ipa.nw.ru> To: skaller@ozemail.com.au Cc: yann@lrde.epita.fr, caml-list@inria.fr Subject: Re: [Caml-list] sorting Hashtbl.t From: "Alexander V.Voinov" In-Reply-To: <3D5AD6CF.7030603@ozemail.com.au> References: <200208120108.VAA16373@dewberry.cc.columbia.edu> <20020812101020.GV6002@barcelona.lrde.epita.fr> <3D5AD6CF.7030603@ozemail.com.au> X-Mailer: Mew version 2.2 on Emacs 21.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi 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. Alexander ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners