title: Sort JSON data by Date/Time value
body: <p>Hope someone could help with this small task. I have an array of text blocks that have a DateTime value assigned to them. I would like to publish those text blocks sorted by DateTime so that the latest updated item is always on top.</p>
  
  <p>Here is the script:</p>
  
  <pre><code>function jsonCallBack(data) {
    var strRows = "";
  
    $.each(data.News, function(i, item) { 
      var htmlNewsBody = item["htmlNewsBody"];            
      var maxLength = 120
      var trimmedString = htmlNewsBody.substr(0, maxLength);
  
      trimmedString = trimmedString.substr( 0, Math.min( trimmedString.length, 
                                                         trimmedString.lastIndexOf(" ") ) );
  
      strRows += "&lt;div id='nrNewsItem-" + i + "'&gt;";
      strRows += "&lt;h3&gt;" + item["txtTitle"] + "&lt;/h3&gt;";
      strRows += "&lt;p&gt;" + item["dtDateTime"] + "&lt;/p&gt;";
      strRows += "&lt;p&gt;" + trimmedString + "...&lt;/p&gt;";
      strRows += "&lt;/div&gt;"
    });
  
    $("#printHere").html(strRows);
  };
  </code></pre>
  
  <p>Also have a <a href="http://jsfiddle.net/VQVb4/1/" rel="nofollow">working jsFiddle with JSON data</a>.</p>