BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help needed to sort array (sort on enumerated data type).

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Students
View previous topic :: View next topic  
Author Message
Peter Eric (aka 'pew') WI
Guest





PostPosted: Thu Feb 01, 2007 3:28 pm    Post subject: Help needed to sort array (sort on enumerated data type). Reply with quote



Hello All,
I am working on a game (a many year project!) and I have defined the
var "move_choices: move_choices_type;" & I need to sort the "move:
array[1..8*3] of move_record;" by the ordinal value of the
move_record's move_value (which is type of move_type enumerated value).

Would someone please be kind enough to paste up some code to sort the
"move" (of type move_records). Note that the will always be only 24
records in the array so the speed of the sort routine in not important
(eg even a slow sort routine would be okay... as it only needs to sort
24 records).

Any & all help appreciated.

Regards,
PEW Wink))
Hobart, Tas, AU.

---------------
//....

type
move_type = (winning_move,
essential_take,
safe_protective_take,
unsafe_protective_take,
safe_defensive_take,
unsafe_defensive_take,
safe_take,
unsafe_take,
best_clear_run,
has_won,
resignation,
safe_protective_move,
unsafe_protective_move,
safe_defensive_move,
unsafe_defensive_move,
best_forward_move,
safe_move,
unsafe_move,
stalemate,
may_lose,
losing_move,
current_X_move,
current_O_move,
current_player_X_move,
current_player_O_move,
rejected,
illegal);

win_type = (no_winner,
O_human,
X_human,
stalemated,
O_computer,
X_computer);

pattern_type = record
this_game: integer;
option: option_type;
x_piece,
o_piece: board_data_type;
end;

directions_type = (left_take, forward_move, right_take);

move_record = record
move_value : move_type;
pawn_number : byte;
direction: directions_type;
end;

move_choices_type = record
option_count: integer;
move: array[1..8*3] of move_record;
end;

var
move_choices: move_choices_type;
//...

---- end
--
Yours Truely,
PEW (poet)
Back to top
Patrick
Guest





PostPosted: Wed Feb 07, 2007 12:48 am    Post subject: Re: Help needed to sort array (sort on enumerated data type) Reply with quote



Is using an ArrayList an option? IList supports the ISort interface.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Students All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.