K
Kent
Hi!
I want to store data (of enemys in a game) as a linked list, each node will
look something like the following:
struct node
{
double x,y; // x and y position coordinates
struct enemy *enemydata; // Holds information about an enemy (in a game)
// Its a double linked list node
struct node *prev;
struct node *next;
};
Each node´s x and y coordinates in the linked list changes for every frame.
Before drawing the enemys to the game screen (graphic memory) i would like
to sort the entire list based on the y coordinate (lowest first).
My question is, wich sort algorithm do you recommend? As it is a linked
list, i thought that insertion sort would work as a linked list is insertion
sort´s "best case". But i would like some opinions from more experienced
programmers about this. Please excouse my poor english, it is not my native
language.
Best regards,
Kent
I want to store data (of enemys in a game) as a linked list, each node will
look something like the following:
struct node
{
double x,y; // x and y position coordinates
struct enemy *enemydata; // Holds information about an enemy (in a game)
// Its a double linked list node
struct node *prev;
struct node *next;
};
Each node´s x and y coordinates in the linked list changes for every frame.
Before drawing the enemys to the game screen (graphic memory) i would like
to sort the entire list based on the y coordinate (lowest first).
My question is, wich sort algorithm do you recommend? As it is a linked
list, i thought that insertion sort would work as a linked list is insertion
sort´s "best case". But i would like some opinions from more experienced
programmers about this. Please excouse my poor english, it is not my native
language.
Best regards,
Kent