Java script sorting

by Yogesh Rathod

JavaScript

// define the Car class
(function() {
    // makeClass - By John Resig (MIT Licensed)
    // Allows either new User() or User() to be employed for construction.
    function makeClass(){
        return function(args){
            if ( this instanceof arguments.callee ) {
                if ( typeof this.init == "function" )
                    this.init.apply( this, (args && args.callee) ? args : arguments );
            } else
                return new arguments.callee( arguments );
        };
    }

    Car = makeClass();

    Car.prototype.init = function(make, model, price, topSpeed, weight) {
        this.make = make;
        this.model = model;
        this.price = price;
        this.weight = weight;
        this.topSpeed = topSpeed;
    };
})();


// create a list of cars
var autos = [
    new Car("Chevy", "Corvair", 1800, 88, 2900),
    new Car("Buick", "LeSabre", 31000, 138, 3700),
    new Car("Toyota", "Prius", 24000, 103, 3200),
    new Car("Porsche", "911", 92000, 155, 3100),
    new Car("Mercedes", "E500", 67000, 145, 3800),
    new Car("VW", "Passat", 31000, 135, 3700)
];

 var data = [
     {
     id:1,
     name:'IRA-5200',
     remainingAmount:5763,
     totalAmount: 8921923.00,
     change:-0.08
   },
    {
     id:2,
     name:'AAA-1812',
     remainingAmount:2010100.20,
     totalAmount: 18514838.10,
     change:0.21
   },
    {
     id:3,
     name:'IRA-5200',
     remainingAmount:5763,
     totalAmount: 8921923.00,
     change:-0.08
   },
    {
     id:4,
     name:'AAA-3810',
     remainingAmount:10050054.07,
     totalAmount: 22788182.64,
     change:0.07
   },
    {
     id:5,
     name:'AAA-0029',
     remainingAmount:39160334.42,
     totalAmount: 84068720.13,
     change:-0.07
   },
    {
     id:6,
     name:'IRA-0146',
     remainingAmount:15884302.39,
     totalAmount: 8921923.00,
     change:0.03
   }
     ,
    {
     id:7,
     name:'REG-2019',
     remainingAmount:13465679.34,
     totalAmount: 0.00,
     change:0.00
   }
  ...