I'd like to sort this (I have many more columns of different data types in the real df):
import pandas as pd
from natsort import index_natsorted
import numpy as np
data = {"version":["3.1.1","3.1.10","3.1.2","3.1.3", "4.1.6"],
"id":[2,2,2,2,1]}
df = pd.DataFrame(data)
df.sort_values(by=["id","version"], key=lambda x: np.argsort(index_natsorted(df["version"])), ignore_index=True)
version id
3.1.1 2
3.1.2 2
3.1.3 2
3.1.10 2
4.1.6 1