|
Joined: May 2000
Posts: 243
Member
|
Member
Joined: May 2000
Posts: 243 |
Ok, say I have a bunch of files that I want to open, get a number. Then sort the files based on that number. I thought of useing a hash. But I don't have much experience in useing hashes. Anyone have any suggestions? ------------------ My Freeware Board
|
|
|
|
Joined: May 2000
Posts: 243
Member
|
Member
Joined: May 2000
Posts: 243 |
No, say I have a files named 1.3df, 2.3df, ect ect.. I want to open them. Then get a number out of the file. The files are setup like this: Name|Name|Name|Name|$Number|Name| And I want to get the $Number and sort it by that. ------------------ My Freeware Board
|
|
|
|
Joined: Aug 2000
Posts: 3,590
Moderator
|
Moderator
Joined: Aug 2000
Posts: 3,590 |
Using a has is probably the simplest way, that I know of anyway. I am sure there are better ways though. Open the file, put the file name as the key, and the number as the...whatever it is called, then sort by the key...
------------------ Da Wannabe Cannuck
|
|
|
|
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
|
P.I.T.A. / Programmer
Joined: Sep 2000
Posts: 755 |
Correction, put the value into the key and the file name into the value, as he apparently (still can't fully understand what he is asking) wants to go through the list of files, open each one, read in a value, then sort the filenames in accordance with what value was found inside.
so if 2df had #9 and 3df had #2 then he would want the files in order as:
3df 2df
I think.
Given that, values in the hash, sort keys, print out.
Zanardi, please learn how to FULLY explain, with lots of details. It will only help you.
--mark
"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
|
|
|
|
Joined: May 2000
Posts: 243
Member
|
Member
Joined: May 2000
Posts: 243 |
Yeah Mark, your right. To exactly tell you what I'm doing. This is part of the news script I made at my site: http://www.outpostd34.com/3do In the '3do Archives' Section near the bottom I have a table called "Latest 10 3do's", and you see it has listed. Rating and the number of downloads it has. Well I want to change it to the 10 most downloaded files. Everytime someone clicks on to download a file. It opens up the $filename.3df (The $filename variable is the number of which the news file was added. thats how I get the number) and then adds 1 to the current number of downloads. So I want to open all the files. And sort them by the number of downloads the have. This is what one of the files looks like: 15|zanardi| [email protected]|Jedi Knight|A shotgun. Works with dflt.mat. Has custom textures|9-24-00|zanardi| [email protected]|Shot Gun|dflt.cmp|shotgun.zip|nshot.jpg|2|2|7|weapon| The first number 2 that you see (Feild number 12) is the number of downloads the file has. the other numbers are just part of the rating system. Hope that helps ya a little bit. ------------------ My Freeware Board
|
|
|
|
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
|
P.I.T.A. / Programmer
Joined: Sep 2000
Posts: 755 |
K but you still haven't answered what the output should be.
Do you want to list the files in order of the numbers (high to low) found at field 12?
--mark
"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
|
|
|
|
Joined: May 2000
Posts: 243
Member
|
Member
Joined: May 2000
Posts: 243 |
Yes, In order, high - low. Feild 12 ![[Linked Image]](https://ubbdev.com/ubb/smilies/smile.gif) ------------------ My Freeware Board
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 1,157
Joined: July 2001
|
|
Forums63
Topics37,575
Posts293,931
Members13,823
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|