I have a snippet for my examples, i need best practice of sorting algorithm with asc, desc convertion. this snippet have many complex for according to job, because string numbers always required in array. how can i simplify this snippet.
const data = [['aaa','22'], ['aba','23'],['baa','12'],['caa','122']]
console.log(data)
console.log('\n')
var columnIndex = 0;
var order = 'DESC';
data.sort((a, b) => {
  if (!Number.isInteger(Number.parseInt(a[columnIndex]))) {
      if (a[columnIndex] < b[columnIndex]) {
          return order === "ASC" ? -1 : 1;
      }
      if (a[columnIndex] > b[columnIndex]) {
          return order === "ASC" ? 1 : -1;
      }
      return 0;
  }
  else {
      return order === "ASC" ? (Number(a[columnIndex].match(/(\d+)/g)) - Number((b[columnIndex].match(/(\d+)/g)))) : ( Number((b[columnIndex].match(/(\d+)/g))) - Number(a[columnIndex].match(/(\d+)/g)));
  }
});
console.log(data);
 
    