Based on this link (http://runrev.screenstepslive.com/s/les ... t-an-array), I created an array sorting function which somehow does not exactly what it should but I cannot see the problem.
I run
Code: Select all
put sortedArray(tArrayIndexFile) into tArrayIndexFileSorted
with
Code: Select all
function sortedArray @pArray
local tSortedArray
local tNextIndex
# fetch the keys and sort them using the array entry values
get the keys of pArray
sort lines of it by pArray[each]
split it by return
# create a new sorted array using the mapped keys
put 1 into tNextIndex
put pArray[tIndex] into tSortedArray[tNextIndex]
add 1 to tNextIndex
end repeat
return tSortedArray
end sortedArray
My data is:
For the original index tArrayIndexFile
Code: Select all
1: Bblanapl, Hans
2: Ablanalp, Henry
3: Abt, Heinrich
4: Abt, Roman
Code: Select all
1. Abt, Heinrich
2. Abt, Roman
3. Bbplanalp, Hans
4. Ablanalp, Henri
I cannot spot the problem... Well, while writing this post I just noticed that it actually (seems to) sort by the first names for 3 and 4 as well.
Running LiveCode 6.0.2 on Mac
Thanks,
Pascal