`Dataset.class_encode` should support custom class names
{'login': 'Dref360', 'id': 8976546, 'node_id': 'MDQ6VXNlcjg5NzY1NDY=', 'avatar_url': 'https://avatars.githubusercontent.com/u/8976546?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/Dref360', 'html_url': 'https://github.com/Dref360', 'followers_url': 'https://api.github.com/users/Dref360/followers', 'following_url': 'https://api.github.com/users/Dref360/following{/other_user}', 'gists_url': 'https://api.github.com/users/Dref360/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/Dref360/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/Dref360/subscriptions', 'organizations_url': 'https://api.github.com/users/Dref360/orgs', 'repos_url': 'https://api.github.com/users/Dref360/repos', 'events_url': 'https://api.github.com/users/Dref360/events{/privacy}', 'received_events_url': 'https://api.github.com/users/Dref360/received_events', 'type': 'User', 'site_admin': False}
[{'id': 1935892871, 'node_id': 'MDU6TGFiZWwxOTM1ODkyODcx', 'url': 'https://api.github.com/repos/huggingface/datasets/labels/enhancement', 'name': 'enhancement', 'color': 'a2eeef', 'default': True, 'description': 'New feature or request'}]
[]
["Hi @Dref360, thanks a lot for your proposal.\r\n\r\nIt totally makes sense to have more flexibility when class encoding, I agree.\r\n\r\nYou could even further customize the class encoding by passing an instance of `ClassLabel` itself (instead of replicating `ClassLabel` instantiation arguments as `Dataset.class_encode_column` arguments).\r\n\r\nAnd the latter made me think of `Dataset.cast_column`...\r\n\r\nMaybe better to have some others' opinions @lhoestq @mariosasko "
 "Hi @Dref360! You can use [`Dataset.align_labels_with_mapping`](https://huggingface.co/docs/datasets/master/package_reference/main_classes.html#datasets.Dataset.align_labels_with_mapping) after `Dataset.class_encode_column` to assign a different mapping of labels to ids.\r\n\r\n@albertvillanova I'd like to avoid adding more complexity to the API where it's not (absolutely) needed, so I don't think introducing a new param in `Dataset.class_encode_column` is a good idea.\r\n\r\n"
 "I wasn't aware that it existed thank you for the link.\n\nClosing then! "]
I can make a PR, just wanted approval before starting.

**Is your feature request related to a problem? Please describe.**

It is often the case that classes are not ordered in alphabetical order. Current `class_encode_column` sort the classes before indexing.
https://github.com/huggingface/datasets/blob/master/src/datasets/arrow_dataset.py#L1235

**Describe the solution you'd like**
I would like to add a **optional** parameter `class_names` to `class_encode_column` that would  be used for the mapping instead of sorting the unique values.

**Describe alternatives you've considered**

One can use map instead. I find it harder to read.
```python
CLASS_NAMES = ['apple', 'orange', 'potato']
ds = ds.map(lambda item: CLASS_NAMES.index(item[label_column]))

# Proposition
ds = ds.class_encode_column(label_column, CLASS_NAMES)
```

**Additional context**

I can make the PR if this feature is accepted.

{'url': 'https://api.github.com/repos/huggingface/datasets/issues/3762/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}