GroupKFold inconsistent under ties in group sizes.

### Describe the bug

Due to the use of argsort (a non stable sort withthout the stable parameter introduced in numpy 2.0), GroupKFold is not always reproducible when there are ties in group sizes.

### Steps/Code to Reproduce

You may need to run this on different machines, but you can reproduce this issue with even less code than GroupKFold by simply testing `np.argsort`.
```
import numpy as np

x = np.array([0.37454012, 0.95071431, 0.73199394, 0.        , 0.15601864,
       0.        , 0.05808361, 0.86617615, 0.60111501, 0.70807258,
       0.02058449, 0.96990985, 0.83244264, 0.21233911, 0.18182497,
       0.18340451, 0.30424224, 0.52475643, 0.43194502, 0.29122914,
       0.61185289, 0.13949386, 0.29214465, 0.36636184, 0.45606998,
       0.78517596, 0.19967378, 0.51423444, 0.59241457, 0.        ,
       0.60754485, 0.17052412, 0.06505159, 0.        , 0.96563203,
       0.80839735, 0.        , 0.        , 0.68423303, 0.44015249,
       0.12203823])

print(np.argsort(x))
```
Both times with numpy version: 1.26.4
machine a: `array(3,5,29,33,36,37,10,6,32,40...`
machine b: `array(37,36,3,29,5,33,10,6,32,40...`

### Expected Results

Technically a stable sort isn't required, no need to maintain the original ordering. However a consistent sort result is required for reproducibility.  Stable sort is an easy way to achieve this that is already built into numpy.

### Actual Results

Both times with numpy version: 1.26.4
machine a: `array(3,5,29,33,36,37,10,6,32,40...`
machine b: `array(37,36,3,29,5,33,10,6,32,40...`

### Versions

```shell
sklearn versions are mostly irrelevant here as the issue is with calling a numpy method that requires additional changes.
```

COMMENT:
To add to the importance of the issue with a scenario I've encountered.

---

Got the same issue in the Kaggle Notebooks environment using one of the competition's data when switching between CPU and GPU instances.
CPU instance was used in dev phase. And for final submissions with GPU - results were quite different.
Pinpointing that the reason was in the data splitting (that I wasn't expecting to have any randomization) took a while. And thanks to @blitchj and this thread I was able to pinpoint it sooner.

## Steps/Code to Reproduce
- Code:
```python
import numpy as np
from sklearn.model_selection import GroupKFold

X = np.zeros(50)
groups = np.repeat(np.arange(25), 2)

group_kfold = GroupKFold(n_splits=2)
for i, (train_index, test_index) in enumerate(group_kfold.split(X, groups=groups)):
    print(f"Fold {i}:")
    print(f"  Train: index={train_index[:5]}..., group={groups[train_index][:5]}...")
```
- Run on different machines.  I've tested in different Kaggle Notebooks instance types - CPU vs GPU (below)

## Actual Results
See in Kaggle: [CPU version](https://www.kaggle.com/code/vladyslavkha/groupkfold-unstability-cpu/) vs [GPU version](https://www.kaggle.com/code/vladyslavkha/groupkfold-unstability-gpu)

---

Also, the docs don't really mention the unstable nature of the GroupKFold neither in [GroupKFold docs](https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GroupKFold.html), nor in the [Visualizing cross-validation behavior in scikit-learn](https://scikit-learn.org/stable/auto_examples/model_selection/plot_cv_indices.html#sphx-glr-auto-examples-model-selection-plot-cv-indices-py).

Hoping https://github.com/scikit-learn/scikit-learn/pull/29496 will be merged soon.
@blitchj, thank you for raising and working on this!

Labels: Bug