The problem is if I enter 1, then 2 and 123. It will sort 1,123,2.
How do i make it sort 1,2,123
Item is the Records that was created. Runner is the traverser.
struct Records {
string Name;
string ID;
char Gender;
string Phone_Num;
Records *Next;
};
void SortRecords(Records* Item, Records* head, Records** Set_Head){
Records* Runner = head;
if (head == NULL){
*Set_Head = Item;
}else if (Item->ID<head->ID){
Item->Next=head;
}else{
while(Item->ID>head->ID){
if(Item->ID > Runner->ID && Runner->Next==NULL){
Runner->Next=Item;
break;
}else if(Item->ID<Runner->Next->ID){
Item->Next=Runner->Next;
Runner->Next=Item;
Runner=Item;
cout<<Runner->Next->Name<<endl;
break;
}else{
Runner=Runner->Next;
}
}
}
stringis reallystd::stringthen you're programming in C++ and should not use the C language tag.'1'will be smaller than any other string beginning with e.g.'2'.