#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Denton, TX 76205
    Posts
    7
    Rep Power
    0
    I am having huge problems with the array_multisort function.

    Background:
    I am tracking the number of hits to my webserver. So I track IP address plus the number of hits.

    I have an array called $ip_total
    [ip address goes here][count goes here].

    Needed:
    I need to sort this array in descending order. (Highest hits first).

    Example:

    Before sort -
    111.111.111.111 5
    222.222.222.222 1
    333.333.333.333 8

    After sort -
    333.333.333.333 8
    111.111.111.111 5
    222.222.222.222 1

    Please help!!!

    Either help me with the function or design a better solution.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    9
    Rep Power
    0
    i use something like that for sorting vote results and their associated labels:

    //sort array $score along w/ array $domain
    //$list_size is the nb of element in array $score (or $domain)

    for ($pass=1; $pass<$list_size; $pass++){

    for ($i=0; $i < $list_size - $pass; $i++){

    if ($score[$i] < $score[$i+1]) { //switch arrays

    $temp1=$score[$i];
    $temp2=$domain[$i];

    $score[$i]=$score[$i+1];
    $domain[$i]=$domain[$i+1];

    $score[$i+1]=$temp1;
    $domain[$i+1]=$temp2;
    }
    }
    }

Similar Threads

  1. Can u find a solution for me !! Javascript commandButtons() funtion
    By arun99907 in forum JavaScript Development
    Replies: 5
    Last Post: December 24th, 2003, 01:17 AM
  2. help i php funtion
    By gui_pt in forum PHP Development
    Replies: 2
    Last Post: August 28th, 2003, 02:20 PM
  3. changing PHP funtion into perl function
    By robbyd in forum Perl Programming
    Replies: 1
    Last Post: July 18th, 2003, 07:37 PM
  4. header funtion for perl
    By robbyd in forum Perl Programming
    Replies: 13
    Last Post: July 18th, 2003, 11:18 AM
  5. Replies: 4
    Last Post: July 9th, 2003, 06:06 AM

IMN logo majestic logo threadwatch logo seochat tools logo