Repository: numpy/numpy
File: numpy/_core/src/umath/_scaled_float_dtype.c (C)

Code before:
    return atimsort_double(in, out, N, NULL);
}


NPY_NO_EXPORT int
sfloat_default_argsort_loop(
        PyArrayMethod_Context *context,
        char *const *data,
        const npy_intp *dimensions,
        const npy_intp *strides,
        NpyAuxData *NPY_UNUSED(auxdata))
{
    PyArrayMethod_SortParameters *parameters = (PyArrayMethod_SortParameters *)context->parameters;
    assert(parameters->flags == NPY_SORT_DEFAULT);
    assert(strides[0] == sizeof(npy_float64));
    assert(strides[1] == sizeof(npy_intp));

    npy_intp N = dimensions[0];
    char *in = data[0];
    npy_intp *out = (npy_intp *)data[1];

    return aquicksort_double(in, out, N, NULL);
}


NPY_NO_EXPORT int
sfloat_argsort_get_loop(
        PyArrayMethod_Context *context,
        int aligned, int move_references,
        const npy_intp *strides,
        PyArrayMethod_StridedLoop **out_loop,
        NpyAuxData **out_transferdata,
        NPY_ARRAYMETHOD_FLAGS *flags)
{
    PyArrayMethod_SortParameters *parameters = (PyArrayMethod_SortParameters *)context->parameters;

    if (PyDataType_FLAGCHK(context->descriptors[0], NPY_NEEDS_PYAPI)) {
        *flags |= NPY_METH_REQUIRES_PYAPI;
    }

    if (parameters->flags == NPY_SORT_STABLE) {
        *out_loop = (PyArrayMethod_StridedLoop *)sfloat_stable_argsort_loop;
    }
    else if (parameters->flags == NPY_SORT_DEFAULT) {
        *out_loop = (PyArrayMethod_StridedLoop *)sfloat_default_argsort_loop;
    }
    else {
        PyErr_SetString(PyExc_RuntimeError, "unsupported sort kind");
        return -1;
    }
    return 0;

Review comment (suggestion):
I think we should now combine this with `sfloat_init_ufuncs`, to show you can do all of them in one go!

Code after:
        {0, NULL}
    };
    PyArrayMethod_Spec multiply_spec = {
        .nin = 2,
        .nout = 1,
        .dtypes = all_sfloat_dtypes,
        .slots = multiply_slots,
        .name = "sfloat_multiply",
        .casting = NPY_NO_CASTING,
    };

    PyType_Slot add_slots[3] = {
        {NPY_METH_resolve_descriptors, &add_sfloats_resolve_descriptors},
        {NPY_METH_strided_loop, &add_sfloats},
        {0, NULL}
    };
    PyArrayMethod_Spec add_spec = {
        .nin = 2,
        .nout = 1,
        .dtypes = all_sfloat_dtypes,
        .slots = add_slots,
        .name = "sfloat_add",
        .casting = NPY_SAME_KIND_CASTING,
    };

    PyArray_DTypeMeta *sort_dtypes[2] = {&PyArray_SFloatDType, &PyArray_SFloatDType};
    PyType_Slot sort_slots[3] = {
        {NPY_METH_resolve_descriptors, &sfloat_sort_resolve_descriptors},
        {NPY_METH_get_loop, &sfloat_sort_get_loop},
        {0, NULL}
    };
    PyArrayMethod_Spec sort_spec = {
        .nin = 1,
        .nout = 1,
        .dtypes = sort_dtypes,
        .slots = sort_slots,
    };
    sort_spec.name = "sfloat_sort";
    sort_spec.casting = NPY_NO_CASTING;
    sort_spec.flags = NPY_METH_NO_FLOATINGPOINT_ERRORS;

    PyArray_DTypeMeta *argsort_dtypes[2] = {&PyArray_SFloatDType, &PyArray_IntpDType};
    PyType_Slot argsort_slots[3] = {
        {NPY_METH_resolve_descriptors, &sfloat_argsort_resolve_descriptors},
        {NPY_METH_get_loop, &sfloat_argsort_get_loop},
        {0, NULL}
    };
    PyArrayMethod_Spec argsort_spec = {
        .nin = 1,
        .nout = 1,
        .dtypes = argsort_dtypes,