Jul 23, 2017 · 1 min read
Thanks for the interesting article!
I noticed an error in your sort callback. It can’t just return 1 or -1, it has to distinguish between all three possibilities and return a positive value for greater than, negative for less than, or zero for equal. The greater than and less than results can be any positive or negative value; they don’t have to be specifically 1 or -1.
Since the time_block property is a number, you can easily do this by subtracting the two values:
all_times.sort( ( a, b ) => a.time_block - b.time_block )
There’s also some interesting feedback from other people in the Reddit discussion.
