I have the following array of objects:
   [
     {
       "id" : 1,
       "pricePerDay" : 50,
     }, 
     {
       "id" : 2,
       "pricePerDay" : 70   
     }
   ]
Based on the user input from a  i want to filter either ASC or DESC on the pricePerday. Obviously this would work with:
 this.products.sort((a, b) => parseFloat(b.pricePerDay) - parseFloat(a.pricePerDay));
BUT i have the variable filterType which now contains the string 'pricePerDay'. How can I use this variable to search the array of objects to properties that have the same key and sort this array based on that key?
 
     
    