Sort and To JSON