I have an array like this. I need to write a function to pass in any two fields and have it sorted. example sort('company_id', 'title') should first sort by company_id and then title. How to write a generic function for it
This is the array and my logic:
 [ {
    id: 11861,
    deadline: '01/13/2020',
    status: 'printed',
    buyer_name: 'Dion Murray PhD'
  },
  {
    id: 11848,
    deadline: '12/14/2019',
    status: 'published',
    buyer_name: 'Dion Murray PhD'
  },
  {
    id: 11849,
    deadline: '12/14/2019',
    status: 'published',
    buyer_name: 'Dion Murray PhD'
  },
  {
    id: 11857,
    deadline: '12/22/2019',
    status: 'new',
    buyer_name: 'Dion Murray PhD'
  }
]
sort ( dataToSort, sortField1 , sortField2) {
       rawData.dataToSort( (a, b) => (a[sortField1] > b[sortField1]) ? 1 : ((a[sortField2] > b[sortField2) ? 1 : -1)} ```
TIA.
 
     
     
     
    