# setof sorting

Posted by maccaroo
Announcements Last Post
myUnisa availability 21 to 24 March 2019 03/17/2019 02:24PM
SoC Curricula 09/30/2017 01:08PM
Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
School of Computing Short Learning Programmes 11/24/2014 08:37AM
Unisa contact information 07/28/2011 01:28PM
 setof sorting August 19, 2006 05:42PM IP/Host: ---.vic.mweb.co.za Registered: 13 years ago Posts: 26 Rating: 0
Hello.

Ass3 Q4 is mostly done, except that I'm not sure how to get setof to return the lists in sorted order. The merge function is fine, but how do tell setof that the sum of the F/H values must be used as a criteria for ordering?

The documentation says

"setof/3 is like bagof/3 above except the list List is sorted according to the standard order and any duplicates are removed."

Umm, what exactly is the 'standard order', and what if you're inclined towards a new (world) order?
 Re: setof sorting August 23, 2006 09:32PM IP/Host: ---.vic.mweb.co.za Registered: 13 years ago Posts: 26 Rating: 0
I'll assume that the stunned silence means that noone else has a clue how to get setof to order the list according to the F+H criteria we need.

Please could one of the lecturers (or anybody smarter than me) shed some light on this one.

Much appreciated, Mac
 Anonymous User Re: setof sorting August 24, 2006 09:42AM IP/Host: 168.210.128.--- Rating: 0
No comment cause I am still on q2
 Re: setof sorting August 24, 2006 09:39PM IP/Host: ---.vic.mweb.co.za Registered: 13 years ago Posts: 26 Rating: 0
Q2 eh? Are you still having trouble finding a good representation of the data?

I didn't use the obvious (r2, r2, 0 , r5, r5) representation, 'cos I couldn't figure out a good way to swap the space with a coin. Instead, I used (Space, r2/Location, r2/Location, r5/Location, r5/Location) as the representation. That way it's much easier to create functions which swap the space 1 or 2 places in either direction.

Hope that helps.
Sorry, only registered users may post in this forum.