title: primeng:p-table custom sort for date format DD.MM.YYYY HH:mm
body: <p>I work on angular4 and primeng <code>&lt;p-table&gt;</code>. My code has a table which displays a <code>courseComplete</code> column. The <code>courseComplete</code> displays date format as <code>DD.MM.YYYY HH:mm</code> which I need to sort. I did implement custom sort for  but sorting is not working as expected.</p>
  
  <p>In ascending sort, data is coming as: (seems time is not getting properly sorted)</p>
  
  <pre><code>29.06.2018 03:11
  29.06.2018 01:57
  01.07.2018 05:35
  </code></pre>
  
  <p>Please guide me where did I go wrong in sorting. Below is my code: <strong>( as of now date is in string format, should the type be changed? I am also using pagination, can this be the issue?)</strong></p>
  
  <pre><code>&lt;p-table [columns]="cols" [value]="course" (sortFunction)="customSort($event)" [customSort]="true"&gt;
      &lt;ng-template pTemplate="header" let-columns&gt;
          &lt;tr&gt;
              &lt;th *ngFor="let col of columns" [pSortableColumn]="col.date"&gt;
                  Course Completed On
                  &lt;p-sortIcon [field]="col.date"&gt;&lt;/p-sortIcon&gt;
              &lt;/th&gt;
          &lt;/tr&gt;
      &lt;/ng-template&gt;
  &lt;/p-table&gt;
  
  customSort(event: SortEvent) {
          event.data.sort((data1, data2) =&gt; {
              let value1 = data1[event.field];
              let value2 = data2[event.field];
              let result = null;
  
              if (value1 == null &amp;&amp; value2 != null)
                  result = -1;
              else if (value1 != null &amp;&amp; value2 == null)
                  result = 1;
              else if (value1 == null &amp;&amp; value2 == null)
                  result = 0;
              else if (typeof value1 === 'string' &amp;&amp; typeof value2 === 'string')
                  result = value1.localeCompare(value2);
              else
                  result = (value1 &lt; value2) ? -1 : (value1 &gt; value2) ? 1 : 0;
  
              return (event.order * result);
          });
      }
  </code></pre>