title: Implementing ADT Priority Que as linked list, can't sort elements
body: <p>I am implementing Abstract Data Type - Priority que, but I can't find out how to put values in correct order.
  My structures:</p>
  
  <pre><code>typedef int kintyr;
  
  typedef struct qElem {
      struct qElem *prv;          
      kintyr *dat;                    
      int *priority;
  }qElem;
  
  
  typedef struct que {
      qElem *fr,*bk;              
      int cnt;                    
  }que;
  </code></pre>
  
  <p>And now my main functions to implement a Priority que</p>
  
  <p>First to create an empty PQ:</p>
  
  <pre><code>que *qNew()
  {
      que *q = malloc(sizeof(*q));
  
      if (q==NULL)
          return NULL;
  
      q-&gt;fr = NULL;
      q-&gt;bk = NULL;
      q-&gt;cnt = 0;
  
  
      qFault = 0;
      return q;
  }
  </code></pre>
  
  <p>This is function to add elements, but it isnt working</p>
  
  <pre><code>que *qEnq(que *q, kintyr *x, int *prrt)
  {
      que *zn=q;
      qFault = 0;
      if (q == NULL)
      {
          qFault = 1;
          return q;
      }
      if (qCHKf(q) == 1)
      {
          qFault = 3;
          return q;
      }
      qElem *new = malloc(sizeof(*new));
      new-&gt;prv = NULL;
      new-&gt;dat = x;
      new-&gt;priority=prrt;
  
      if (q-&gt;fr == NULL || prrt &lt; q-&gt;fr-&gt;priority ) 
      {
          q-&gt;fr = new;
  
      }
      else
      {
          que *temp=q;
          while(temp-&gt;fr!=NULL&amp;&amp;q-&gt;fr-&gt;priority &lt;= prrt)
              temp = temp-&gt;fr;
  
          new-&gt;prv=temp-&gt;fr;
          temp-&gt;fr=new;
          //if (temp-&gt;bk != NULL) 
          //q-&gt;bk-&gt;prv = new; 
  
          q-&gt;bk = new; }}
  
  
  
          q-&gt;cnt++; 
          return q;
      }
  }
  </code></pre>
  
  <p>Do you have any thoughts how can i fix this?</p>