# sort_by The order in which an object’s keys are written. ## Synopsis ```perl my $json = JSON::PP->new->sort_by(sub { $JSON::PP::b cmp $JSON::PP::a }); ``` ## What you get back The object. A code reference, or the name of a sub in JSON::PP, sorts the keys, comparing `$JSON::PP::a` with `$JSON::PP::b`; any other true value sorts them as `canonical` does.