A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: [AS3]Array.sortOn not accurate?

Threaded View

  1. #1
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188

    [AS3]Array.sortOn not accurate?

    Ok, here's some code I used :

    Code:
    var transformedSurfaces:Array=surfaces.sortOn("depth",Array.DESCENDING|Array.NUMERIC);
    for(var i:int=0;i<transformedSurfaces.length;i++) {
    	trace(transformedSurfaces[i].depth);
    }
    And this is the result I got :


    Code:
    205.44603367212753
    182.78833899621128
    160.130644320295
    138.99973123326004
    138.99973123326004
    138.99973123326004
    138.99973123326004
    138.99973123326004
    138.99973123326004
    114.81525496846251
    114.81525496846251
    114.81525496846251
    92.15756029254628
    92.15756029254628
    90.63077870366499
    90.63077870366499
    90.63077870366499
    73.72604823403702
    69.49986561663002
    48.368952529595056
    48.36895252959505
    48.36895252959505
    48.36895252959505
    37.47373675257102
    37.47373675257102
    30.242796788862044
    30.242796788862044
    24.18447626479752
    24.18447626479752
    1.5267815888812777
    0
    0
    0
    0
    0
    -24.184476264797524
    -24.184476264797524
    -24.184476264797524
    -42.26182617406994
    -42.26182617406994
    -46.84217094071377
    -48.36895252959505
    -48.36895252959505
    -48.36895252959505
    0
    -82.178413468851
    -82.178413468851
    -82.178413468851
    -2.5357095704441965
    -8.452365234813989
    -89.10399711478371
    -90.63077870366499
    -90.63077870366499
    -21.130913087034973
    -31.696369630552457
    -132.89260487773493
    -132.89260487773493
    -137.47294964437876
    -138.99973123326006
    -138.99973123326006
    -138.99973123326006
    -157.07708114253245
    -172.80919217251602
    -172.80919217251602
    -172.80919217251602
    -181.26155740733
    -181.26155740733
    -181.26155740733
    -205.44603367212753
    -223.52338358139994
    -228.10372834804377
    -263.43997087618095
    -263.43997087618095
    -263.43997087618095
    -271.89233611099496
    -271.89233611099496
    -271.89233611099496
    -314.15416228506496
    -362.52311481465995
    -362.52311481465995
    -362.52311481465995
    -362.52311481465995
    -362.52311481465995
    -362.52311481465995
    -404.7849409887299
    -495.41571969239493
    -495.41571969239493
    -495.41571969239493
    -495.41571969239493
    -495.41571969239493
    -495.41571969239493
    -495.41571969239493
    Note that there's a zero out of place.

    I also tried a simple Array.sort(Array.DESCENDING|Array.NUMERIC), and had the toString() function of my objects return the depth field, and that way it was accurate but a lot slower.

    So, any ideas?

    Thanks.
    Last edited by Fall_X; 08-01-2007 at 02:25 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center