Sortwith results different on Mac vs Windows

Has anyone encountered this scenario?

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

ParseArray and DeckArray code is missing so its hard to diagnose why this might be

ParseArray contains string representations of a double deck of cards and DeckArray contains pictures elements of the double deck of cards.

@Doron Kauper — Simple rule: if there’s a different between Mac and Windows, then Windows is wrong.

OK, I’m out… :smiley:

[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).

“Information required”, like would Feedback say…

Sounds right to me.

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.

Ok. I should perhaps start to use API2 before posting…

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.

Love this forum!

Sorting in windows and mac does differ… non letters, accented characters, upper/lowercase

Would still be interesting to know what the contents of DeckArray actually are

The base array, tmparray(), contains integers. Surely these should sort identically on both platforms?

DeckArray is images.

Have you tried comparing the data in ParseArray() on both platforms?

I’m also curious. Are you sure that val(parseArray(I)) is always resulting in a unique value? It sounds to me like you’ve either got some duplicates or they’re all converting to zeros and the sort becomes ambiguous.

Pictures?
What is the ‘defined sort order’ for an image?

Image NAMES, yeah. … Image PATHS…
But an object? Binary representation? Size?

@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.