Refactored petfinderSort.js script