adding logic for sorting json object