Arrays & Array Methods (map, filter, reduce)

What custom sorting logic is implemented?
const nums = [3, 1, 4, 1, 5, 9, 2, 6, 5];
const sorted = [...nums].sort((a, b) => {
  if (a % 2 === b % 2) return a - b;
  return a % 2 - b % 2;
});
Next Question (19/20)