JavaScript: Basic Sort Function