0π
β
I got similar result when omitting the return
, it will give you response, but re-sorting wonβt work.
Therefore, just use return a.weight - b.weight;
instead of a simple a.weight - b.weight;
Detailed explanation : https://stackoverflow.com/a/38159151/3256489
Source:stackexchange.com