Search Sorting Searching - Sorting the Results FieldNamesort=N
Searches and sorts the results.

You may sort the results of any search so [FoundItems] appear in a particular order. Ranking by "best match," ascending or descending alphabetically or numerically, random, "none," and multiple fields are all possible.

Note: if you do not specify a sort order explicitly, then WebDNA assumes you want the results sorted by "best match," meaning the records which match the most search terms will be shown at the top of the list. This is very powerful, because even if thousands of records are found (by a careless choice of too-common search words such as "a" "and" "the"), usually the "best" records are at the top of the list.

For example, if you want to sort alphabetically by First Name amongst all the records whose First Name is after "H," you would enter something like this:

grFirstNamedata=H&FirstNamesort=1

"gr" stands for "greater than", and "sort=1" means the primary sort order is based on FirstName field. You can have a secondary sort order based on other fields (meaning that when several FirstName fields are identical, those records are sub-sorted by another field). For example, to sort by FirstName and then LastName you would enter something like:

grFirstNamedata=H&FirstNamesort=1&LastNamesort=2

"sort=2" tells WebDNA to alphabetize the LastName records within portions of the results that have identical FirstName fields.

Note: fields are sorted within equally-ranked groups of found items, which means that all the "best match" records at the top of the list get sorted alphabetically, then the "next-best" records are sorted after that, and so on. Often, if it is important that records be sorted purely alphabetically (ignoring their 'rank'), you will need to put "AllHit=1" into your search criteria.

Which Fields to Sort (FieldNamesort=N)
Sort by FirstName FirstNamesort=1
Sort by LastName first, then FirstName FirstNamesort=2&LastNamesort=1
Sort Order (FieldNamesdir=XX)
Sort FirstName Ascending (A-Z or 0-9 if numeric) FirstNamesdir=as
Sort FirstName Descending (Z-A or 9-0 if numeric) FirstNamesdir=de
Sort FirstName Randomly (useful for random banner ads) FirstNamesdir=ra

Note: sometimes you need a series of random sorts to always present the exact same 'random' order. You can force the randomizer to return items in the same order if you add another parameter "RandSeed=879" (or any other integer number). This is most helpful when you use [ShowNext] and you need each successive set of links to predictably return the results in the same order.
No sorting of any kind -- records are displayed in exactly the same order they appear in the database file. rank=off
Turn Best Match Ranking Default Off -- records are sorted without best match ranking. AllHit=1

User Contributed Notes
SearchSorting  

Copyright © 2008 WebDNA Software Corporation, Inc.