Re: Trouble with sorting

From: Date: Tue, 27 Jun 2000 17:36:19 +0000
Subject: Re: Trouble with sorting
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3394@lists.php.net to get a copy of this message
On Tue, Jun 27, 2000 at 05:22:01PM -0900, Ildar Akhmetov wrote: > I have two text files. One file, named 'players', contains names of > soccer-players, next file, named 'votes', contains votes for each > player. Strings numbers are same (#1 in players is #1 in votes, and so > on). > > I need to diaplay a table with player ratings, sorted by rating. How can > I do this? You could use file() to read each of the files in as an array. Then you should be able to sort them easily. If th eonly relationship between the player and his votes is position in the file, you may want to combine the two arrays into a single array: $players = file(...); $votes = file(...); for($i=0; $i <count($players); $i++){ $key = $players[$i]; $playervotes["$key"] = $votes[$i]; } ------ Then you can use one of the array sort functions to sort them. -- Chris Moyer -- cmoyer@chekinc.com -- PHP Developer -- Chek.com

« previous php.general (#3394) next »