title: HIVE GROUP_CONCAT with ORDER BY
body: <p>I have a table like</p>
  
  <p><a href="https://i.stack.imgur.com/4bqF2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4bqF2.png" alt="Source table"></a></p>
  
  <p>I expect the output like this (group concat the results in one record, and the group_concat should sort the results by value DESC).</p>
  
  <p><a href="https://i.stack.imgur.com/XTyj1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XTyj1.png" alt="Destination table"></a></p>
  
  <p>Here is the query I tried,</p>
  
  <pre><code>SELECT id,
         CONCAT('{',CONCAT_WS(',',GROUP_CONCAT(CONCAT('"',key, '":"',value, '"'))), '}') AS value
  FROM
      table_name
  GROUP BY id
  </code></pre>
  
  <p>I want the value in the destination table should be sorted (descending order) by source table value.</p>
  
  <p>To do that, I tried doing <strong>GROUP_CONCAT(... ORDER BY value)</strong>.</p>
  
  <p>Looks like Hive does not support this. Is there any other way to achieve this in hive?</p>