code: def test_unsorted_indices(csr_container):
      # test that the result with sorted and unsorted indices in csr is the same
      # we use a subset of digits as iris, blobs or make_classification didn't
      # show the problem
      X, y = load_digits(return_X_y=True)
      X_test = csr_container(X[50:100])
      X, y = X[:50], y[:50]
  
      X_sparse = csr_container(X)
      coef_dense = (
          svm.SVC(kernel="linear", probability=True, random_state=0)
          .fit(X, y)
          .coef_
      )
      sparse_svc = svm.SVC(
          kernel="linear", probability=True, random_state=0
      ).fit(X_sparse, y)
      coef_sorted = sparse_svc.coef_
      # make sure dense and sparse SVM give the same result
      assert_allclose(coef_dense, coef_sorted.toarray())
  
      # reverse each row's indices
      def scramble_indices(X):
          new_data = []
          new_indices = []
          for i in range(1, len(X.indptr)):
              row_slice = slice(*X.indptr[i - 1 : i + 1])
              new_data.extend(X.data[row_slice][::-1])
              new_indices.extend(X.indices[row_slice][::-1])
          return csr_container(
              (new_data, new_indices, X.indptr), shape=X.shape
          )
  
      X_sparse_unsorted = scramble_indices(X_sparse)
      X_test_unsorted = scramble_indices(X_test)
  
      assert not X_sparse_unsorted.has_sorted_indices
      assert not X_test_unsorted.has_sorted_indices
  
      unsorted_svc = svm.SVC(
          kernel="linear", probability=True, random_state=0
      ).fit(X_sparse_unsorted, y)
      coef_unsorted = unsorted_svc.coef_
      # make sure unsorted indices give same result
      assert_allclose(coef_unsorted.toarray(), coef_sorted.toarray())
      assert_allclose(
          sparse_svc.predict_proba(X_test_unsorted),
          sparse_svc.predict_proba(X_test),
      )
  
imports: import numpy
  import pytest
  from scipy import sparse
  from sklearn import base, datasets, linear_model, svm
  from sklearn.datasets import load_digits, make_blobs, make_classification
  from sklearn.exceptions import ConvergenceWarning
  from sklearn.svm.tests import test_svm
  from sklearn.utils._testing import assert_allclose, assert_array_almost_equal, assert_array_equal, ignore_warnings, skip_if_32bit
  from sklearn.utils.extmath import safe_sparse_dot
  from sklearn.utils.fixes import CSR_CONTAINERS, DOK_CONTAINERS, LIL_CONTAINERS
label_desc: Use image node_id 3 for calling a global function with example usage: test_unsorted_indices(csr_container) and returns: csr_container