I have a code like this and I am getting (Move this array "sort" operation to a separate statement) at the very start
pkgList
.sort(this.compare)
.map((item) => item.name)
but when i refactor to
const sortedPkgList = pkgList.sort(this.compare);
sortedPkgList
.map((item) => item.name)
I am still getting the same (Move this array "sort" operation to a separate statement). I am not sure what this error means and how to usually solve this kind of problem? THanks!