#include "userroot.h"
userroot::userroot()
{
   djpoint_10=0;
   AAA_count=0;
   AA_count=0;
   A_count=0;
   B_count=0;
   C_count=0;
   D_count=0;
   E_count=0;
   F_count=0;
   perfect=0;
   combo=0;
   clear=0;
   play=0;
}
void userroot::sort()
{
   entry temp;
   temp.nextsong=this->head;
   this->head=&temp;                         //address of entry that points to head
                                             //list ===> [temp] -> 1st -> 2nd -> 3rd -> etc.

   entry* sortend=this->head;                //sortend->nextsong is first unsorted element in list

   while(sortend->nextsong!=NULL)            //last one to sort is second from end
   {
      entry* lowest=sortend;
      for(entry* seek=sortend; seek->nextsong!=NULL; seek=seek->nextsong)
         if(seek->nextsong->title<lowest->nextsong->title)
            lowest=seek;                     //adr of entry previous to lowest

      if(lowest!=sortend)                     //only if change is necessary, otherwise don't bother
      {
         entry* n1=sortend->nextsong;          //  sortend ->[n1]-> UNSORTED
         entry* n2=lowest->nextsong;           //   lowest ->[n2]-> UNSORTED
         lowest->nextsong=lowest->nextsong->nextsong; //   lowest ---n2--> UNSORTED
         n2->nextsong=n1;                     //             n2 -> n1 -> UNSORTED
         sortend->nextsong=n2;                //  sortend -> n2 -> n1 -> UNSORTED
      }
      sortend=sortend->nextsong;
   }

                                             //remove temporary entry
   this->head=this->head->nextsong;          //head ====temp====> real data
}
