Sorting JavaScript objects

Along with the ability to efficiently find objects that match a criteria, you will often require your objects to be in a certain order for outputting.

Getting ready

As with the previous recipe, create an HTML page named recipe-5.html where we can add and execute JavaScript code for this recipe using the following code:

<!DOCTYPE html>
<html>
<head>
  <title>Chapter 3 :: AJAX & JSON</title>
  <script src="jquery.min.js"></script>
  <script >

  </script>
</head>
<body></body>
</html>

Update the reference to the jQuery library in order to ensure that it includes the correct file on your computer.

How to do it…

Create a reusable function to sort a JavaScript object by performing the following step-by-step instructions:

  1. Within the script ...

Get jQuery 2.0 Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.