title: Sort Mongodb data by price
body: <p>Goal: I'm trying to find a way to let a user sort rentals by max and min price on the one index page.</p>
  
  <p>My problem is the only way I could figure out how to make it work was to create two separate pages specifically for lowprice and highprice. I want to only have one main index.</p>
  
  <p>The pricelow page shown below filters the data from low to high prices</p>
  
  <pre><code>        app.get("/pricelow", function(req, res){
          Listings.find({}).sort({price: 1}).exec(function(err, allListings){
                 if(err){
                     console.log(err);
                 } else {
                 res.render("pricelow",{listings:allListings});
                 }
            })
      });
  </code></pre>
  
  <p>//The pricehigh page shown below filters the data from high to low prices</p>
  
  <pre><code>app.get("/pricehigh", function(req, res){
      Listings.find({}).sort({price: -1}).exec(function(err, allListings){
                 if(err){
                     console.log(err);
                 } else {
                 res.render("pricehigh",{listings:allListings});
                 }
            })
      });
  </code></pre>