title: how to insert values in sorted order in Guava Table values
body: <p>I've been trying to insert some values in sorted order in Table structure for Guava, below is my piece of code</p>
  
  <pre><code>NodeDetails node1 = new NodeDetails();
  NodeDetails node2 = new NodeDetails();
  NodeDetails node3 = new NodeDetails();
  
  node1.setCLOUDTYPE("aws");
  node1.setNODENAME("node1");
  
  node2.setCLOUDTYPE("cloudstack");
  node2.setNODENAME("node2");
  
  node3.setCLOUDTYPE("azure");
  node3.setNODENAME("node3");
  
  Table&lt;String, String, Object&gt; table = TreeBasedTable.create();
      table.put("vmstat_usage", "cpu_idle", node1);
      table.put("vmstat_usage", "cpu_idle", node2);
      table.put("vmstat_usage", "cpu_idle", node3);
      table.put("vmstat_usage_percent", "cpu_system", node3);
  
  Gson gson = new GsonBuilder().serializeNulls().setPrettyPrinting()
                      .create();
  System.out.println(gson.toJson(table.rowMap()));
  </code></pre>
  
  <p>Here NodeDetails is implementing Comparable with which I want to sort the values... But when I'm taking the values of rowMap the same is overriding with existing values. So only one object is returning.</p>
  
  <p>If I create TreeMultimap I'm getting all the objects inserted in collection correctly.</p>
  
  <p>I'm trying to create this kind of response through this.</p>
  
  <pre><code>{
    "vmstat_usage": {
      "cpu_idle":      {
          "CLOUD_TYPE": "azure",
          "NODE_NAME": "node3",
        },
        {
          "CLOUD_TYPE": "aws",
          "NODE_NAME": "node1",
        },
        {
          "CLOUD_TYPE": "cloudstack",
          "NODE_NAME": "node2",
          "NODE_PRIVATE_IP_ADDRESS": null
        }
    },
    "vmstat_usage_percent": {
      "cpu_idle": {
        "CLOUD_TYPE": "azure",
        "NODE_NAME": "node3",
      }
    }
  }
  </code></pre>
  
  <p>I've gone through this link <a href="https://stackoverflow.com/questions/11256840/sorting-guava-table-on-values">Sorting Guava table on values</a> and found that "table.rowMap returns a SortedMap>. So the map is sorted on it's row keys, but the Map value is an unsorted map"<br>
  As suggested here <a href="https://stackoverflow.com/questions/7001582/java-sort-a-guava-treebasedtable">Java Sort a Guava TreeBasedTable</a> I can create a new TreeTable with defined comparator and put my previous Table in there or <a href="http://www.wenda.io/questions/2486554/sorting-guava-tables-in-descending-order-based-on-values.html" rel="nofollow noreferrer">http://www.wenda.io/questions/2486554/sorting-guava-tables-in-descending-order-based-on-values.html</a> I can create new Ordering while create the Table.</p>
  
  <p>I tried something like this but it's not working.</p>
  
  <pre><code>Table&lt;String, String, NodeDetails&gt; table2 = TreeBasedTable.create(Ordering.natural(), Ordering.natural());
  table2.putAll(table);
  </code></pre>
  
  <p>Please give me an example for how to do this. </p>