diff --git a/sort/dw_matrix_sort.c b/sort/dw_matrix_sort.c
index e187d4f7196c233f9ae2c119a6fe950dc730ee96..537244432d614cf69ed3f6b39d37f2c3f4667f7a 100644
--- a/sort/dw_matrix_sort.c
+++ b/sort/dw_matrix_sort.c
@@ -184,7 +184,7 @@ TVector SortVectorAscending(TVector x, TVector y)
       dw_Error(NULL_ERR);
       return (TVector)NULL;
     }
-  if ((x != x) && !(x=EquateVector(x,y)))
+  if ((x != y) && !(x=EquateVector(x,y)))
     return (TVector)NULL;
   b_qsort_array_ascending_real(pElementV(x),DimV(x));
   return x;
@@ -213,7 +213,7 @@ TVector SortVectorDescending(TVector x, TVector y)
       dw_Error(NULL_ERR);
       return (TVector)NULL;
     }
-  if ((x != x) && !(x=EquateVector(x,y)))
+  if ((x != y) && !(x=EquateVector(x,y)))
     return (TVector)NULL;
   b_qsort_array_descending_real(pElementV(x),DimV(x));
   return x;