Sorts list of dicts by key in the given direction.