Thanks but it’s not what I want. By the way I finally made myself
It just doesn’t work if there’re identical values 
local function sortIndex(t) local tb1,tb2,tb3={},{},{} for i=1,#t do tb1[tostring(t[i])]=i end for key,value in pairs(tb1) do tb2[#tb2+1]=key end table.sort(tb2) for i=1,#tb2 do tb3[#tb3+1]=tb1[tb2[i]] end return tb3 end local t1={5,3,1,2,4} local t2=sortIndex(t1) for i=1,#t2 do print(t2[i]) end