Home > Enterprise >  What's wrong on order these data by a, than by b, than by c conditions?
What's wrong on order these data by a, than by b, than by c conditions?

Time:06-23

enter image description here

CodePudding user response:

Hmm, it works for me:

Here's a sandbox: https://codesandbox.io/s/funny-antonelli-bk3j9t?file=/src/App.js

Could it be that your sort function has a return statement on it's own line, and therefore returns undefined?

EDIT: That seems to be the case, didn't notice your fiddle but if you update it to:

arr.sort(function (a, b) { return (a.side.toString().localeCompare(b.side.toString()) || a.completed.toString().localeCompare(b.completed.toString() || b.lastUpdate.toString().localeCompare(a.lastUpdate.toString()))) });

It looks like it updates the sorting order to the one you describe.

  • Related