For the life of me, I can't seem to figure this one out and I've been doing some forum searches ("array sort" and "array sort single" thinking that perhaps the issue is sorting real numbers) that have thus far been unhelpful.
Here's the relevant code:
I'm basically taking an array of my "player" UDT and storing a key to "sort by" in the array called sSortArray(). Admittedly, the majority of players don't have a value - there are a ton of 0's in this array. However, there are a few players who have a value that's a real number between 0 and 1 and others that have a value above 0 and approximately 7 to 8. However, when I view my file with the printed sSortArray, I get this:
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
.072
0
0
0
0
0
0
0
0
0
0
0
0
3.496296
and then more zeros, and then some more numbers, out of order. I know this must be something ridiculous that I'm not seeing right now. I'd be grateful if anyone has any idea what I'm missing. Eventually, I want to attach player() as a TAGARRAY on this list, but I'm in the midst of troubleshooting and have removed that from the equation.
Thank you!
Here's the relevant code:
Code:
LOCAL sSortArray() AS SINGLE REDIM sSortArray(1 TO UBOUND(player())) FOR x = 1 TO UBOUND(player) IF player(x).iOutsAtPosition(1) > 10 THEN sSortArray(x) = ((13 * player(x).iHomeRunsAllowed + 3 * player(x).iWalksAllowed - 2 * player(x).iStrikeOutsAllowed) / (player(x).iOutsAtPosition(1) / 3)) + 3.2 ELSE 'sSortArray(x) = (0.72xNIBB + 0.75xHBP + 0.90x1B + 0.92xRBOE + 1.24x2B + 1.56x3B + 1.95xHR) / PA sSortArray(x) = (0.72 * player(x).iWalks + 0.90 * (player(x).iHits - player(x).iDoublesTotal - player(x).iTriplesTotal - player(x).iHomeRunsTotal) _ + 1.24 * player(x).iDoublesTotal + 1.56 * player(x).iTriplesTotal + 1.95 * player(x).iHomeRunsTotal) / (player(x).iAtbats + player(x).iWalks) END IF NEXT x ARRAY SORT sSortArray() FOR x = 1 TO UBOUND(sSortArray()) WRITE #iFileNum(1), sSortArray(x) NEXT x
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
.072
0
0
0
0
0
0
0
0
0
0
0
0
3.496296
and then more zeros, and then some more numbers, out of order. I know this must be something ridiculous that I'm not seeing right now. I'd be grateful if anyone has any idea what I'm missing. Eventually, I want to attach player() as a TAGARRAY on this list, but I'm in the midst of troubleshooting and have removed that from the equation.
Thank you!
Comment