#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    56
    Rep Power
    28

    Sorting array starting index


    I have an array saved (saved data at bottom of post), then I reload it. The save and retrieval system is working.

    I am wondering if anyone can tell me why the values entered on the form start at 20 for the item with the lowest value instead of 0 or 1, and also why there are gaps in the numbering? The code actually achieves my goal which is to take the numbers in the array and make them less than 32,767 while maintaining their order, but I expected SortArray.indexOf(quantexisting[which]) to return 1,2,3,4,5,6 once the page had been sorted not start at 20?

    This is not a major issue, I am just curious why it is doing that.

    PHP Code:
    function parseDisplay()
        {
        
    //step=sort sort page
        //step=add add page
        //step=remove remove page
        
        
    switch(formfields["step"])
            {
            case 
    "add":
            case 
    "remove":
                break;
            case 
    "sort":
                
    //quantexisting[itemnum] = qinexist;
                //<input autocomplete="off" name="sort[]" size="4" maxlength="4" value="5001" type="text">
                
    SortArray quantexisting.slice();
                
    SortArray.sort(function(ab){return b;});
                
    //array.indexOf(searchElement)
                
    $('input[name="sort[]"]').each(function ()
                    {
                    $(
    this).attr('size''20');
                    $(
    this).attr('maxlength''20');
                    
    which = $(this).parent().siblings('input[type="hidden"]').attr('value');
                    $(
    this).attr('value'SortArray.indexOf(quantexisting[which]));                
                    });
                break;            
            }    
        } 

    Contents of quantexisting array before this code executes.
    0=0,1=871561,2=198298,3=83411,4=49356,5=47642,6=35800,7=35127,8=13157,9=34790,10=51909,11=29247,12=9 2381,13=38463,14=28422,15=24855,16=63314,17=17072,18=19529,19=42538,20=8714,21=38074,22=46154,23=569 88,24=56317,25=19292,26=26378,27=21152,28=18190,29=16012,30=48392,31=9573,32=28004,33=37700,34=10935 ,35=389237,36=1028983,37=328377,38=86902,39=793518,40=765917,41=71401,42=428142,43=153045,44=224621, 45=165532,46=305885,47=247186,48=8363210,49=92585,50=18221,51=200745,52=227144,53=457048,54=105742,5 5=42590,56=67224,57=160513,58=152450,59=81596,60=1295413,61=1157440,62=77154,63=12550,64=407316,65=1 04234,66=14558224,67=4184344,68=7259534,69=262938,70=47004,71=62761,72=22265,73=108237,77=264702,78= 288586,79=21177,80=21361,81=56600,82=21365,83=56295,84=24442,85=63561,86=59023,87=57686,88=55557,89= 259109,90=69085,91=65883,92=66868,93=60862,94=77553,95=260256,96=73236,97=2524453,99=10482,102=64,10 3=54214,104=11268,105=9921,107=10489,108=7056,110=65219,111=14725,115=20,118=31,119=20,129=233029,13 0=19,140=20,141=20,145=23458,146=15567,147=26072,151=20351,154=32633,155=20,159=229873,160=7892,162= 20,167=2257,171=367,172=37288,173=37220,174=24008,175=18211,176=20271,177=5242,178=4544,179=877,180= 6283483,181=87665,182=336793,183=2213741,184=107723,185=828,186=2629952,187=11689339,189=77056,190=1 00061,191=82078,194=117,195=120,196=767987,197=485551,198=184601,199=96507,200=65309,201=33071,203=1 43749,204=25942,205=737644,206=660275,209=197255,210=488024,215=1562177,216=350,217=6322,218=13326,2 19=38812,220=216061,221=14420,222=108830,223=17236,224=54750,225=8670,226=20981,227=11830,228=6824,2 29=35483,230=13758,231=4555,232=4370,233=43539,234=5416,235=4203,236=1735,237=59237,238=5247,239=523 36,241=14720,242=268251,243=24065,244=7337,245=6481,246=14404,247=8612,248=11108,249=3021,250=2851,2 51=5486,252=6883,253=11091,254=3710,255=8352,256=17683,257=22466,258=138234,259=34379,260=1206744,26 1=152083,262=87727,263=778072,264=609813,265=52223,266=52359,267=528352,268=67218,269=79069,270=4371 1,271=500905,272=2277606,273=282105,274=64009,275=16672,276=494321,277=475255,278=6903,279=18019,280 =33905,281=86680,282=701778,283=53278,290=2427,293=11187,294=28783,295=20667,296=7349,305=1962,306=2 058,307=2155,308=2144,309=2052,310=3342905,326=16126,327=18641,328=20458,332=6440,333=11788,334=9666 ,335=14720,345=991,346=1835,347=1803,351=19,358=18134,359=10137,360=10414,361=6288,364=13620,365=244 797,366=181407,367=137285,368=11656,369=232360,370=76766,372=763440,377=43688,378=70563,379=115634,3 80=10293,384=54834,385=448790,391=30352,392=129131,393=5313,394=22872125,395=13234,397=706,398=3503, 400=2837,401=110115,402=8044,403=709513,404=87559,405=1202,406=41137,407=9740,408=3743,409=14734,410 =9120,411=4780,412=17165,413=9931,414=11470,415=3898,416=7792,417=70535,418=3070,419=2433,420=2560,4 21=12357,422=1997,426=285843,427=17836,429=12971,430=2685,431=9564,432=300149,433=6987,434=9787,436= 241085,437=12141,438=3293,439=14681,440=2180,441=20,442=20,444=20,450=6321,451=6467,452=6466,453=126 5,454=3359,455=1976,460=9905,461=9957,463=9864,464=7361,465=2572,466=2634,467=16331,469=402,472=9239 ,473=25016,474=10975,475=12464,476=4830,477=25625,478=7412,483=13397,484=14107,485=13880,486=14669,4 87=14511,488=13536,489=13904,490=14841,491=1615,492=1793,493=2158,494=7308,495=9549,496=6152,497=622 3,498=10374,499=10159,500=5092,501=9981,502=4550,503=3372,504=3385,505=12493,506=4422,508=3111,509=4 188,510=2268,511=2175,512=7230,513=2431,514=4526,515=3645,516=2024,517=4780,518=4090,520=3786,521=43 34,522=3423,523=3858,524=3460,527=266741,528=422667,529=552327,530=87627,531=359319,532=68663,533=77 666,534=9927,535=88795,536=75416,537=110508,538=20114,539=10279,540=20713,541=105037,542=102439,543= 7975,544=13380,550=133540,551=134833,552=134116,553=70733,554=81480,555=43661,556=77189,557=16009,55 8=15709,559=59498,560=42422,562=43227,563=2332,564=3192,565=3198,566=3303,567=3264,568=3129,569=3261 ,570=3203,571=3250,572=3327,574=3248,575=3284,576=3361,577=3223,578=3233,579=3345,580=2801,581=5380, 583=5786,584=10483,585=8993,586=29823,587=26672,588=3751,595=5436,596=1371,597=3423,598=1019,599=170 9,600=689,601=4034,602=2762,603=1016,604=948,605=2598,606=2367,607=2436,608=788,609=1638,610=2866,61 1=49356,612=4732,613=3233,614=5690,616=33277,617=675132,618=80370,619=13123,620=50635,621=7421,622=7 005,623=13112,624=20921,625=3897,626=13496,627=2124,628=2247,629=2230,632=1243,633=1037,634=1271,635 =942,636=3456,637=1600,638=2289,639=1500,691=20
    Last edited by efilnikufecin; February 17th, 2013 at 02:49 AM.

IMN logo majestic logo threadwatch logo seochat tools logo