Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: exporting a HashMap Date: Tue, 17 Jan 2012 20:38:36 -0500 Organization: A noiseless patient Spider Lines: 26 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 18 Jan 2012 01:38:38 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="HSlJAUb3pGXi3i7ZL/HoAw"; logging-data="31534"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199zIrKVpIwC+rjDhKURA0e" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 In-Reply-To: Cancel-Lock: sha1:kTaJ6Bsf0GgyGlpZ06IxlkIuqzY= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11443 On 1/17/2012 12:04 PM, Roedy Green wrote: > On Sun, 15 Jan 2012 12:01:55 -0500, Eric Sosman > wrote, quoted or indirectly quoted > someone who said : > >> >> Map map = ...; >> List> entries = >> new ArrayList>(map.entrySet()); >> Collections.sort(entries, new Comparator>() { >> @Override >> public int compare(Map.Entry e1, Map.Entry e2) { >> return e1.getKey().compareTo(e2.getKey()); >> } >> }); >> for (Map.Entry e : entries) { ... } > > I have added your technique with attribution to > http://mindprod.com/jgloss/hashmap.html Thanks. Actually, I thought my other suggestion was slicker, certainly briefer. -- Eric Sosman esosman@ieee-dot-org.invalid