in reply to Search Engine function

It also helps to have the most (likely) relevant hits at the top of list, which means you'll need some kind of ranking system.

This will vary on the type of data returned. You may be able to do a simple sort on a particular column if you are returning results from a dababase.

If it is a more general search, you'll need to do a variety of things, including: more search hits means greater relevance; hits of important words (this is domain-specific) count more than other words; etc.