| |||||||||||
sorting program for golf scores Posted by BJ (BJ), 6 April 2005 Which sorting programs might work for this...i have not much experience in sorters or arrays as of yet...thanks,,...Posted by admin (Graham Ellis), 6 April 2005 Almost every language has its own sorting routines which can be tailored to suit the data, and typically these sort routines are built into the language or system rather that being separate programs. Exactly what and how they work depends on the data involved.Here's an example in Perl: Code:
Like many othe languages, Perl's built in sort routine can take an extra parameter which is the name of a piece of code that tells two records apart by returning a negative, zero or positive response when comparing them to see which is "less" than the other. You'll find links to further (Perl) source code examples at http://www.wellho.net/resources/P211.html for Perl, at http://www.wellho.net/resources/Y111.html for Python and at http://www.wellho.net/resources/H999.html for PHP. Here's the result of running the program (above) to test it: Code:
Posted by BJ (BJ), 8 April 2005 Thank you..that was quite over my head...lol...but at least i have a general idea of how it fits into the overall picture. ...One more question....in order for files etc. to be entered into arrays...do they have to be sorted first?...forgive my ignorance but im only in my first few weeks of programming and logic. we have just begun the study of arrays and sorting methods.....Thanks Posted by admin (Graham Ellis), 8 April 2005 Information can be put into arrays (or lists) in any order ... typically, you'll read a file or a result set from a user and put the information into the array in the order you read it. You then sort it from the array or list and (depending on the language) the results will either be put back into the same array or returned to you as a new array.Posted by BJ (BJ), 8 April 2005 Interesting..I had it backwards...ThanksThis page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |