test: fix array sorting bug

`a === a.sort()` is always true because Array#sort() does an in-place
sort.  Make a copy of the array first.