I have n x 3 ndarray and wanted to sort it by 3-rd column.In 3-rd column there MAY BE some np.inf. Anyway, I used sorted function. After that I used njit decorator on my main function but got different result... So I wrote that code to check what's going on:
#Sorting Functions
import numpy as np
from numba import njit
@njit
def sort_me_numba(arr):
res = sorted(arr, key=lambda x: x[2], reverse=True)
return res
def sort_me_python(arr):
res = sorted(arr, key=lambda x: x[2], reverse=True)
return res
#Making data format I have
arr = np.concatenate([np.random.normal(loc=0.1, scale=0.005, size=1_000).reshape((-1, 1)) for i in range(3)], axis=1)
samples = [0, 14, 53, 344, 43, 654, 435, 33]
arr[samples, 2] = np.inf
print('-----------NUMBA with numpy array------------')
sort_me_numba(arr)
print('-----------PYTHON with numpy array------------')
sort_me_python(arr)
print('-----------PYTHON with list------------')
sort_me_python(list(arr))
And there is really some differences. But when samples = [0, 1, 2, 442] - there is no differences. Why?