Handle equal indices in _.sortBy.

Fix #1247.