Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting my array...

Status
Not open for further replies.

Simmantix

Technical User
Jul 14, 2003
4
0
0
GB
Hi all,

I have a search page, the keywords form a selection routine to bring records from the DB which contain any of the keywords. Each record is then analysed to determine how many of the keywords it has in it and is given a higher rating accordingly. The records are concatenated into a string and then they are put into an array. So I have an array, that array is filled with a strings which are themselves concatenations of:

RecordID&Subject&Text&Date&Rating

The rating is a three digit rating which is assigned to the string based on the amount of matching words within the text. A example array string would be:

2&TestSubject&Hi, this a test...&31/02/2003&050

What I want to do is, having made my array from analysis of recordsets, resort the array based on the rating (highest to lowest) for output onto my web page.

Any ideas would be greatly appreciated.. Also any other ways to do the whole thing would be quite good too, emphasis on simple though.

Thanks in advance

Simm
 
to put you on the right track, here's how to get your rating for that string - as a number variable. Should be easy enough to sort the array based on this.

Code:
dim strTest, intRating
strTest = "2&TestSubject&Hi, this a test...&31/02/2003&050"
intRating = CInt(Right(strTest, 3)) 'get last 3 chars of string & convert them to an int

so - if you loop through your array you can get the rating as an int for each string in your results. Let us know how you get on with trying to sort using this :)


Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
Well, there is always faq329-3362.

Then use GetString( ) or GetRows( ) to pull your data back out into a string or an array.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top