I want to sort a HashMap of timestamps .  Here is my timestamps hashmap.  Map&lt;String, DateTime&gt; timestamps = new HashMap&lt;&gt; ();   I dont know which method i should use to sort this type of hashmaps . So I cant provide any additional code.   Thank you for ur help !
1054
I am relatively new to Java, and often find that I need to sort a Map&lt;Key, Value&gt; on the values.  Since the values are not unique, I find myself converting the keySet into an array, and sorting that array through array sort with a custom comparator that sorts on the value associated with the key.  Is there an easier way?
121226
HashTables/HashMaps are one of the most (if not the most) useful of data-structures in existence.  As such, one of the first things I investigated when starting to learn programming in Cocoa was how to create, populate, and read data from a hashtable.  To my surprise: all the documentation I've been reading on Cocoa/Objective-C programming doesn't seem to explain this much at all.  As a Java developer that uses "java.util" as if it were a bodily function: I am utterly baffled by this.  So, if someone could provide me with a primer for creating, populating, and reading the contents of a hashtable: I would greatly appreciate it.
45890
Question  I'm looking for a Java in-memory object caching API. Any recommendations? What solutions have you used in the past?  Current  Right now, I'm just using a Map:  Map cache = new HashMap&lt;String, Object&gt;(); cache.put("key", value);   Requirements  I need to extend the cache to include basic features like:   Max size Time to live   However, I don't need more sophisticated features like:   Access from multiple processes (caching server) Persistence (to disk)   Suggestions  In-Memory caching:    CacheBuilder - active development. See this .  - Config via API. No TTL. Not purpose built for caching.  - XML config. Mailing list. Last updated 2006.  - XML config. Documentation in Russian. Last updated 2006.   Enterprise caching:    - Properties config. Extensive documentation.  - XML config. Extensive documentation. By far the most popular according to Google hits.
13700
I have a list of objects I wish to sort based on a field attr of type string. I tried using -  list.sort(function (a, b) {     return a.attr - b.attr })   but found that - doesn't appear to work with strings in JavaScript. How can I sort a list of objects based on an attribute with type string?
63275
I'm code reviewing a change one of my co-workers just did, and he added a bunch of calls to Date.toMonth(), Date.toYear() and other deprecated Date methods.  All these methods were deprecated in JDK 1.1, but he insists that it's ok to use them because they haven't gone away yet (we're using JDK 1.5) and I'm saying they might go away any day now and he should use Calendar methods.  Has Sun/Oracle actually said when these things are going away, or does @deprecated just mean you lose style points?
92311
What is an elegant way to sort objects in PHP? I would love to accomplish something similar to this.  $sortedObjectArary = sort($unsortedObjectArray, $Object-&gt;weight);   Basically specify the array I want to sort as well as the field I want to sort on. I looked into multidimensional array sorting and there might be something useful there, but I don't see anything elegant or obvious.
88277
I constantly have problems working with dates in Excel, I must be doing something wrong but I don't understand what.  I have a spreadsheet, exported from our exchange server, that contains a column with dates on. They have come out in US format even though I'm in the UK.   The column in question looks like this  04/08/2012 04/09/2009 04/01/2010 04/21/2011 04/05/2012 08/30/2009 08/29/2010 08/28/2011   In Excel, I have highlighted the column and selected Format Cells.... In this dialog box, I have selected the Date, selected English (United States) as the locale and chosen the matching date format from the list. I hit OK and try to sort the data by this column.   In the sort dialogue I choose this column, select sort on Values but the order only gives me options for A to Z, not oldest to newest as I would expect.  This in turn sorts the date data by the first two digits.  I am aware I could re-format this data to ISO and then the A to Z sort would work but I shouldn't have too, I'm obviously missing something. What is it?  EDIT: I messed up the bounty but this should have gone to @r0berts answer, his first suggestion of Text to Columns with no delimiter and choosing 'MDY' as the type of data works. Additionally, if you have a time (i.e. 04/21/2015 18:34:22), you need to first get rid of the time data. However after that the method suggested by @r0berts works fine.
82376
Which algorithm does the JavaScript Array#sort() function use?  I understand that it can take all manner of arguments and functions to perform different kinds of sorts, I'm simply interested in which algorithm the vanilla sort uses.
12184
I'm trying to get an understanding of what the the java keyword this actually does. I've been reading Sun's documentation but I'm still fuzzy on what this actually does.
77207
I would like to write a function GetHashCodeOfList() which returns a hash-code of a list of strings regardless of order. Given 2 lists with the same strings should return the same hash-code.   ArrayList list1 = new ArrayList()     list1.Add("String1"); list1.Add("String2"); list1.Add("String3");      ArrayList list2 = new ArrayList()     list2.Add("String3");     list2.Add("String2");  list2.Add("String1");  GetHashCodeOfList(list1) = GetHashCodeOfList(list2) //this should be equal.   I had a few thoughts:    I can first sort the list, then combine the sorted list into 1 long string and then call GetHashCode(). However sorting is a slow operation. I can get the hash of each individual string (by calling string.GetHashCode()) in the list, then multiplying all hashes and calling Mod UInt32.MaxValue.  For example: "String1".GetHashCode() * "String2".GetHashCode * … MOD UInt32.MaxValue. But this results in a number overflow.   Does anyone have any thoughts?  Thanks in advance for your help.
51825
I have the name of the "sort by property" in a string. I will need to use Lambda/Linq to sort the list of objects.  Ex:  public class Employee {   public string FirstName {set; get;}   public string LastName {set; get;}   public DateTime DOB {set; get;} }   public void Sort(ref List&lt;Employee&gt; list, string sortBy, string sortDirection) {   //Example data:   //sortBy = "FirstName"   //sortDirection = "ASC" or "DESC"    if (sortBy == "FirstName")   {     list = list.OrderBy(x =&gt; x.FirstName).toList();       }  }    Instead of using a bunch of ifs to check the fieldname (sortBy), is there a cleaner way of doing the sorting Is sort aware of datatype?
67323
Why is a signed integer used to represent timestamps? There is a clearly defined start at 1970 that's represented as 0, so why would we need numbers before that? Are negative timestamps used anywhere?
23131
What is the best way to convert a JSON code as this:  {      "data" :      {          "field1" : "value1",          "field2" : "value2"     } }   in a Java Map in which one the keys are (field1, field2) and the values for those fields are (value1, value2).  Any ideas? Should I use Json-lib for that? Or better if I write my own parser?
41144
As made clear in update 3 on , this notation: var hash = {}; hash[X]  does not actually hash the object X; it actually just converts X to a string (via .toString() if it's an object, or some other built-in conversions for various primitive types) and then looks that string up, without hashing it, in &quot;hash&quot;. Object equality is also not checked - if two different objects have the same string conversion, they will just overwrite each other. Given this - are there any efficient implementations of hashmaps in JavaScript? (For example, the second Google result of  yields an implementation which is O(n) for any operation. Various other results ignore the fact that different objects with equivalent string representations overwrite each other.
46764
I may be teaching a "Java crash-course" soon.  While it is probably safe to assume that the audience members will know Big-O notation, it is probably not safe to assume that they will know what the order of the various operations on various collection implementations is.  I could take time to generate a summary matrix myself, but if it's already out there in the public domain somewhere, I'd sure like to reuse it (with proper credit, of course.)  Anyone have any pointers?
27793
How do I get a method's execution time?   Is there a Timer utility class for things like timing how long a task takes, etc?     Most of the searches on Google return results for timers that schedule threads and tasks, which is not what I want.
18599
I want to return two objects from a Java method and was wondering what could be a good way of doing so?  The possible ways I can think of are: return a HashMap (since the two Objects are related) or return an ArrayList of Object objects.  To be more precise, the two objects I want to return are (a) List of objects and (b) comma separated names of the same.  I want to return these two Objects from one method because I dont want to iterate through the list of objects to get the comma separated names (which I can do in the same loop in this method).  Somehow, returning a HashMap does not look a very elegant way of doing so.