[quote=497232:@Doron Kauper]
Identical code run on Mac and Windows (Version 2019 Release 3.2) yields different sort order for base array elements.
var I As Integer
var tmpArray(103) As Integer
for i = 0 to 103
tmpArray(i) = val(ParseArray(i))
next i
tmpArray.SortWith(DeckArray) //deck of cards array[/quote]
I’m first surprised you don’t get an exception. Your array contains 103 elements and you loop from 0 to 103 (i.e. 104 times); you must get an OutOfBounds exception in this case.
It’s unclear to me as to what kind of difference you’re seeing, since ParseArray and DeckArray aren’t revealed to us (and your description in your previous post doesn’t help understanding or reproducing your issue).
Unless something has changed since the 2016 R1.1 version Xojo I use (like arrays have become 1-based instead of 0-based), then Dim tmpArray(103) (or Var, if you prefer the current syntax) means that “103” is the last element in a zero-based array … which means it will hold 104 elements … which makes his statement correct.
Thank you for your replies above. I’ve done additional testing and found a clear difference in results from sortWith in Mac and Windows. Rather than beat my head against the wall, I’ve written a short function that accomplishes the same thing and is consistent between platforms.
Im also curious. Are you sure that val(parseArray(I)) is always resulting in a unique value? It sounds to me like youve either got some duplicates or theyre all converting to zeros and the sort becomes ambiguous.
@Doron Kauper Have you been able to deduce a specific pattern to the differences in Sort order? Is the whole sort different (e.g. backwards) or is it just specific items out of place? Perhaps you can post a short sample of the different order of integers in the arrays between Windows and Mac.