Expose API endpoint to order Legend's entries.

Close #1408.
`sort()` works in place. Shallow-copy the domain before sorting to avoid messing up the scale.