+ 17

Array sorting. HELP😱

I have such array: ["1,5 x 1m", "2,5 x 2 m", "1x2,5m", "no", "1,4 x 2 m", "9 x 1,4m + 1,5 x 4m", "yes", "1,4 x 2,3 m" ] I need such output: [ "yes", "no", "1x2,5m", "1,4x2m", "1,4x2,3m", "1,5x1m", "2,5x2m", "9x1,4m+1,5x4m", ]; How to sort source array more effectively, concise and elegant? ONLY JAVASCRIPT SOLUTION!!! PS. I know it's simple, but can't guess how... Should I use sort(), filter(), map() and so on functions and tricky callback? Notice,commas in elements and different spaces in source array!

17th Feb 2018, 4:36 PM
\__(° = °)__/
10 odpowiedzi
+ 15
it's interesting🤓
17th Feb 2018, 7:47 PM
\__(° = °)__/
+ 15
Thanks, Aleksey👏
18th Feb 2018, 7:23 AM
\__(° = °)__/
+ 14
Real programming consists entirely of such boring things😁 And usually you don't have time to enjoy and use new tecnologies. In a real market, you need to solve about such problems.😏 Of course you can create cool animations and interesting logic, but clients need from your code to work everywhere and steadily
17th Feb 2018, 8:17 PM
\__(° = °)__/
17th Feb 2018, 11:35 PM
Алексей Р.
Алексей Р. - avatar
+ 12
And I knew it too😉. Give me the ready solution, @silent. I know theory rather well, but can't to solve many tasks yet, @silent
17th Feb 2018, 5:14 PM
\__(° = °)__/
+ 11
yes, I knew it, but thanks to you, @silent
17th Feb 2018, 5:11 PM
\__(° = °)__/
+ 8
I knew that you knew this, too. And as for the ready solution, it is necessary to think, it is long and tedious... :(
17th Feb 2018, 5:19 PM
Vladislav Tikhiy (SILENT)
Vladislav Tikhiy (SILENT) - avatar
+ 8
Nope. It's boring and needs to think about it.
17th Feb 2018, 7:48 PM
Vladislav Tikhiy (SILENT)
Vladislav Tikhiy (SILENT) - avatar
+ 7
I started doing this with `Array.prototype.sort()`... and I was tired. I think we should split the values ​​like "9x1,4m+1,5x4" into multiple parts, go through them with `parseFloat()` or `parseInt()` (I do not understand this), and compare by these values. I think I said obvious things that will not help
17th Feb 2018, 5:07 PM
Vladislav Tikhiy (SILENT)
Vladislav Tikhiy (SILENT) - avatar
+ 7
If commas can be replaced with points, then it is easier.
17th Feb 2018, 5:10 PM
Vladislav Tikhiy (SILENT)
Vladislav Tikhiy (SILENT) - avatar