void sort(Tria[] tr, int[] colorCode, float[] zTr, int l, int r)
{  int i = l, j = r,  wInt;
   float x = zTr[(i + j)/2], w;
   Tria wTria;
   do
   {  while (zTr[i] < x) i++;
      while (zTr[j] > x) j--;
      if (i < j)
      {  w = zTr[i]; zTr[i] = zTr[j]; zTr[j] = w;
         wTria = tr[i]; tr[i] = tr[j]; tr[j] = wTria;
         wInt = colorCode[i]; colorCode[i] = colorCode[j];
         colorCode[j] = wInt;
         i++; j--;
      } else
   if (i == j) {i++; j--;}
} while (i <= j);
if (l < j) sort(tr, colorCode, zTr, l, j);
if (i < r) sort(tr, colorCode, zTr, i, r);
}