handle sort for JSON