Index: /trunk/psLib/src/collections/Makefile
===================================================================
--- /trunk/psLib/src/collections/Makefile	(revision 1110)
+++ /trunk/psLib/src/collections/Makefile	(revision 1111)
@@ -3,6 +3,6 @@
 ##  Makefile:   collections
 ##
-##  $Revision: 1.21 $  $Name: not supported by cvs2svn $
-##  $Date: 2004-06-18 23:36:27 $
+##  $Revision: 1.22 $  $Name: not supported by cvs2svn $
+##  $Date: 2004-06-28 20:36:37 $
 ##
 ##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,5 +35,6 @@
            psImage.o \
            psList.o \
-           psScalar.o
+           psScalar.o \
+           psCompare.o
 
 # Define PHONY target "all" which will make all the necessary items
Index: /trunk/psLib/src/collections/psCompare.c
===================================================================
--- /trunk/psLib/src/collections/psCompare.c	(revision 1111)
+++ /trunk/psLib/src/collections/psCompare.c	(revision 1111)
@@ -0,0 +1,79 @@
+/** @file psCompare.c
+ *  @brief Comparison functions for sorting routines
+ *  @ingroup Compare
+ *
+ *  @author Robert Lupton, Princeton University
+ *  @author Robert Daniel DeSonia, MHPCC
+ *
+ *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-28 20:36:37 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+
+#include "psType.h"
+#include "psCompare.h"
+
+#define compareNumericPtr(TYPE) \
+int psCompare##TYPE##Ptr(const void** a, const void** b) { \
+    return **((ps##TYPE**)a) - **((ps##TYPE**)b); \
+}
+
+#define compareNumericPtrDescending(TYPE) \
+int psCompare##TYPE##DescendingPtr(const void** a, const void** b) { \
+    return **((ps##TYPE**)b) - **((ps##TYPE**)a); \
+}
+
+#define compareNumeric(TYPE) \
+int psCompare##TYPE(const void* a, const void* b) { \
+    return *((ps##TYPE*)a) - *((ps##TYPE*)b); \
+}
+
+#define compareNumericDescending(TYPE) \
+int psCompare##TYPE##Descending(const void* a, const void* b) { \
+    return *((ps##TYPE*)b) - *((ps##TYPE*)a); \
+}
+
+compareNumericPtr(S8)
+compareNumericPtr(S16)
+compareNumericPtr(S32)
+compareNumericPtr(S64)
+compareNumericPtr(U8)
+compareNumericPtr(U16)
+compareNumericPtr(U32)
+compareNumericPtr(U64)
+compareNumericPtr(F32)
+compareNumericPtr(F64)
+
+compareNumericPtrDescending(S8)
+compareNumericPtrDescending(S16)
+compareNumericPtrDescending(S32)
+compareNumericPtrDescending(S64)
+compareNumericPtrDescending(U8)
+compareNumericPtrDescending(U16)
+compareNumericPtrDescending(U32)
+compareNumericPtrDescending(U64)
+compareNumericPtrDescending(F32)
+compareNumericPtrDescending(F64)
+
+compareNumeric(S8)
+compareNumeric(S16)
+compareNumeric(S32)
+compareNumeric(S64)
+compareNumeric(U8)
+compareNumeric(U16)
+compareNumeric(U32)
+compareNumeric(U64)
+compareNumeric(F32)
+compareNumeric(F64)
+
+compareNumericDescending(S8)
+compareNumericDescending(S16)
+compareNumericDescending(S32)
+compareNumericDescending(S64)
+compareNumericDescending(U8)
+compareNumericDescending(U16)
+compareNumericDescending(U32)
+compareNumericDescending(U64)
+compareNumericDescending(F32)
+compareNumericDescending(F64)
Index: /trunk/psLib/src/collections/psCompare.h
===================================================================
--- /trunk/psLib/src/collections/psCompare.h	(revision 1111)
+++ /trunk/psLib/src/collections/psCompare.h	(revision 1111)
@@ -0,0 +1,362 @@
+#if !defined(PS_COMPARE_H)
+#define PS_COMPARE_H
+
+/** @file psCompare.h
+ *  @brief Comparison functions for sorting routines
+ *
+ *  @author Robert Daniel DeSonia, MHPCC
+ *
+ *  @ingroup Compare
+ *
+ *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-28 20:36:37 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+
+/** @addtogroup Compare
+*  @{
+*/
+
+/** A comparison function for sorting elements that are pointers to data,
+ *  e.g., for psList of pointers to numeric values.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+typedef int (*psComparePtrFcn)(const void** a, const void** b);
+
+/** A comparison function for sorting.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+typedef int (*psCompareFcn)(const void* a, const void* b);
+
+/** Compare function of psS8 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS8Ptr(const void** a, const void** b);
+
+/** Compare function of psS16 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS16Ptr(const void** a, const void** b);
+
+/** Compare function of psS32 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS32Ptr(const void** a, const void** b);
+
+/** Compare function of psS64 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS64Ptr(const void** a, const void** b);
+
+/** Compare function of psU8 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU8Ptr(const void** a, const void** b);
+
+/** Compare function of psU16 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU16Ptr(const void** a, const void** b);
+
+/** Compare function of psU32 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU32Ptr(const void** a, const void** b);
+
+/** Compare function of psU64 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU64Ptr(const void** a, const void** b);
+
+/** Compare function of psF32 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareF32Ptr(const void** a, const void** b);
+
+/** Compare function of psF64 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareF64Ptr(const void** a, const void** b);
+
+/** Compare function of psS8 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS8Ptr(const void** a, const void** b);
+
+/** Compare function of psS16 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS16Ptr(const void** a, const void** b);
+
+/** Compare function of psS32 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS32Ptr(const void** a, const void** b);
+
+/** Compare function of psS64 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS64Ptr(const void** a, const void** b);
+
+/** Compare function of psU8 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingU8Ptr(const void** a, const void** b);
+
+/** Compare function of psU16 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingU16Ptr(const void** a, const void** b);
+
+/** Compare function of psU32 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingU32Ptr(const void** a, const void** b);
+
+/** Compare function of psU64 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingU64Ptr(const void** a, const void** b);
+
+/** Compare function of psF32 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingF32Ptr(const void** a, const void** b);
+
+/** Compare function of psF64 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingF64Ptr(const void** a, const void** b);
+
+/** Compare function of psS8 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS8(const void* a, const void* b);
+
+/** Compare function of psS16 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS16(const void* a, const void* b);
+
+/** Compare function of psS32 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS32(const void* a, const void* b);
+
+/** Compare function of psS64 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS64(const void* a, const void* b);
+
+/** Compare function of psU8 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU8(const void* a, const void* b);
+
+/** Compare function of psU16 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU16(const void* a, const void* b);
+
+/** Compare function of psU32 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU32(const void* a, const void* b);
+
+/** Compare function of psU64 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU64(const void* a, const void* b);
+
+/** Compare function of psF32 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareF32(const void* a, const void* b);
+
+/** Compare function of psF64 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareF64(const void* a, const void* b);
+
+/** Compare function of psS8 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS8(const void* a, const void* b);
+
+/** Compare function of psS16 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS16(const void* a, const void* b);
+
+/** Compare function of psS32 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS32(const void* a, const void* b);
+
+/** Compare function of psS64 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS64(const void* a, const void* b);
+
+/** Compare function of psU8 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingU8(const void* a, const void* b);
+
+/** Compare function of psU16 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingU16(const void* a, const void* b);
+
+/** Compare function of psU32 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingU32(const void* a, const void* b);
+
+/** Compare function of psU64 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingU64(const void* a, const void* b);
+
+/** Compare function of psF32 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingF32(const void* a, const void* b);
+
+/** Compare function of psF64 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingF64(const void* a, const void* b);
+
+
+
+/// @}
+
+#endif
Index: /trunk/psLib/src/collections/psList.c
===================================================================
--- /trunk/psLib/src/collections/psList.c	(revision 1110)
+++ /trunk/psLib/src/collections/psList.c	(revision 1111)
@@ -1,11 +1,11 @@
 /** @file psList.c
  *  @brief Support for doubly linked lists
- *  @ingroup DataContainers
+ *  @ingroup LinkedList
  *
  *  @author Robert Lupton, Princeton University
  *  @author Robert Daniel DeSonia, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-23 23:00:15 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-28 20:36:37 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -426,5 +426,4 @@
     arr->n = list->size;
 
-
     ptr = list->head;
     n = list->size;
@@ -459,2 +458,23 @@
     return list;
 }
+
+
+psList* psListSort(psList* list, psCompareFcn compare)
+{
+    psVector* vector;
+    if (list == NULL) {
+        return NULL;
+    }
+
+    // convert to indexable vector for use by qsort.
+    vector = psListToVector(list);
+    psFree(list);
+
+    qsort(vector->data.V, vector->n, sizeof(void*),
+          (int(*)(const void *, const void *))compare);
+
+    // convert back to linked list
+    list = psVectorToList(vector);
+
+    return list;
+}
Index: /trunk/psLib/src/collections/psList.d
===================================================================
--- /trunk/psLib/src/collections/psList.d	(revision 1110)
+++ /trunk/psLib/src/collections/psList.d	(revision 1111)
@@ -1,3 +1,3 @@
 psList.o psList.d : psList.c ../sysUtils/psError.h ../sysUtils/psAbort.h \
-  ../sysUtils/psMemory.h psList.h psVector.h psType.h \
+  ../sysUtils/psMemory.h psList.h psCompare.h psVector.h psType.h \
   ../sysUtils/psTrace.h ../sysUtils/psLogMsg.h
Index: /trunk/psLib/src/collections/psList.h
===================================================================
--- /trunk/psLib/src/collections/psList.h	(revision 1110)
+++ /trunk/psLib/src/collections/psList.h	(revision 1111)
@@ -10,6 +10,6 @@
  *  @ingroup LinkedList
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-23 23:00:15 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-28 20:36:37 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -18,4 +18,5 @@
 #include <pthread.h>                   // we need a mutex to make this stuff thread safe.
 
+#include "psCompare.h"
 #include "psVector.h"
 
@@ -181,5 +182,8 @@
 );
 
+psList* psListSort(psList* list, psCompareFcn compare);
+
 /// @} End of DataGroup Functions
 
 #endif
+
Index: /trunk/psLib/src/math/psCompare.c
===================================================================
--- /trunk/psLib/src/math/psCompare.c	(revision 1111)
+++ /trunk/psLib/src/math/psCompare.c	(revision 1111)
@@ -0,0 +1,79 @@
+/** @file psCompare.c
+ *  @brief Comparison functions for sorting routines
+ *  @ingroup Compare
+ *
+ *  @author Robert Lupton, Princeton University
+ *  @author Robert Daniel DeSonia, MHPCC
+ *
+ *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-28 20:36:37 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+
+#include "psType.h"
+#include "psCompare.h"
+
+#define compareNumericPtr(TYPE) \
+int psCompare##TYPE##Ptr(const void** a, const void** b) { \
+    return **((ps##TYPE**)a) - **((ps##TYPE**)b); \
+}
+
+#define compareNumericPtrDescending(TYPE) \
+int psCompare##TYPE##DescendingPtr(const void** a, const void** b) { \
+    return **((ps##TYPE**)b) - **((ps##TYPE**)a); \
+}
+
+#define compareNumeric(TYPE) \
+int psCompare##TYPE(const void* a, const void* b) { \
+    return *((ps##TYPE*)a) - *((ps##TYPE*)b); \
+}
+
+#define compareNumericDescending(TYPE) \
+int psCompare##TYPE##Descending(const void* a, const void* b) { \
+    return *((ps##TYPE*)b) - *((ps##TYPE*)a); \
+}
+
+compareNumericPtr(S8)
+compareNumericPtr(S16)
+compareNumericPtr(S32)
+compareNumericPtr(S64)
+compareNumericPtr(U8)
+compareNumericPtr(U16)
+compareNumericPtr(U32)
+compareNumericPtr(U64)
+compareNumericPtr(F32)
+compareNumericPtr(F64)
+
+compareNumericPtrDescending(S8)
+compareNumericPtrDescending(S16)
+compareNumericPtrDescending(S32)
+compareNumericPtrDescending(S64)
+compareNumericPtrDescending(U8)
+compareNumericPtrDescending(U16)
+compareNumericPtrDescending(U32)
+compareNumericPtrDescending(U64)
+compareNumericPtrDescending(F32)
+compareNumericPtrDescending(F64)
+
+compareNumeric(S8)
+compareNumeric(S16)
+compareNumeric(S32)
+compareNumeric(S64)
+compareNumeric(U8)
+compareNumeric(U16)
+compareNumeric(U32)
+compareNumeric(U64)
+compareNumeric(F32)
+compareNumeric(F64)
+
+compareNumericDescending(S8)
+compareNumericDescending(S16)
+compareNumericDescending(S32)
+compareNumericDescending(S64)
+compareNumericDescending(U8)
+compareNumericDescending(U16)
+compareNumericDescending(U32)
+compareNumericDescending(U64)
+compareNumericDescending(F32)
+compareNumericDescending(F64)
Index: /trunk/psLib/src/math/psCompare.h
===================================================================
--- /trunk/psLib/src/math/psCompare.h	(revision 1111)
+++ /trunk/psLib/src/math/psCompare.h	(revision 1111)
@@ -0,0 +1,362 @@
+#if !defined(PS_COMPARE_H)
+#define PS_COMPARE_H
+
+/** @file psCompare.h
+ *  @brief Comparison functions for sorting routines
+ *
+ *  @author Robert Daniel DeSonia, MHPCC
+ *
+ *  @ingroup Compare
+ *
+ *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-28 20:36:37 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+
+/** @addtogroup Compare
+*  @{
+*/
+
+/** A comparison function for sorting elements that are pointers to data,
+ *  e.g., for psList of pointers to numeric values.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+typedef int (*psComparePtrFcn)(const void** a, const void** b);
+
+/** A comparison function for sorting.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+typedef int (*psCompareFcn)(const void* a, const void* b);
+
+/** Compare function of psS8 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS8Ptr(const void** a, const void** b);
+
+/** Compare function of psS16 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS16Ptr(const void** a, const void** b);
+
+/** Compare function of psS32 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS32Ptr(const void** a, const void** b);
+
+/** Compare function of psS64 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS64Ptr(const void** a, const void** b);
+
+/** Compare function of psU8 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU8Ptr(const void** a, const void** b);
+
+/** Compare function of psU16 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU16Ptr(const void** a, const void** b);
+
+/** Compare function of psU32 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU32Ptr(const void** a, const void** b);
+
+/** Compare function of psU64 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU64Ptr(const void** a, const void** b);
+
+/** Compare function of psF32 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareF32Ptr(const void** a, const void** b);
+
+/** Compare function of psF64 data.  For use with psListSort.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareF64Ptr(const void** a, const void** b);
+
+/** Compare function of psS8 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS8Ptr(const void** a, const void** b);
+
+/** Compare function of psS16 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS16Ptr(const void** a, const void** b);
+
+/** Compare function of psS32 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS32Ptr(const void** a, const void** b);
+
+/** Compare function of psS64 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS64Ptr(const void** a, const void** b);
+
+/** Compare function of psU8 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingU8Ptr(const void** a, const void** b);
+
+/** Compare function of psU16 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingU16Ptr(const void** a, const void** b);
+
+/** Compare function of psU32 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingU32Ptr(const void** a, const void** b);
+
+/** Compare function of psU64 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingU64Ptr(const void** a, const void** b);
+
+/** Compare function of psF32 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingF32Ptr(const void** a, const void** b);
+
+/** Compare function of psF64 data.  For use with psListSort for descending ordering.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingF64Ptr(const void** a, const void** b);
+
+/** Compare function of psS8 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS8(const void* a, const void* b);
+
+/** Compare function of psS16 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS16(const void* a, const void* b);
+
+/** Compare function of psS32 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS32(const void* a, const void* b);
+
+/** Compare function of psS64 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareS64(const void* a, const void* b);
+
+/** Compare function of psU8 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU8(const void* a, const void* b);
+
+/** Compare function of psU16 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU16(const void* a, const void* b);
+
+/** Compare function of psU32 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU32(const void* a, const void* b);
+
+/** Compare function of psU64 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareU64(const void* a, const void* b);
+
+/** Compare function of psF32 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareF32(const void* a, const void* b);
+
+/** Compare function of psF64 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively less 
+ *                   than, equal to, or greater than the second. 
+ */
+int psCompareF64(const void* a, const void* b);
+
+/** Compare function of psS8 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS8(const void* a, const void* b);
+
+/** Compare function of psS16 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS16(const void* a, const void* b);
+
+/** Compare function of psS32 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS32(const void* a, const void* b);
+
+/** Compare function of psS64 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingS64(const void* a, const void* b);
+
+/** Compare function of psU8 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingU8(const void* a, const void* b);
+
+/** Compare function of psU16 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or less than the second. 
+ */
+int psCompareDescendingU16(const void* a, const void* b);
+
+/** Compare function of psU32 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingU32(const void* a, const void* b);
+
+/** Compare function of psU64 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingU64(const void* a, const void* b);
+
+/** Compare function of psF32 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingF32(const void* a, const void* b);
+
+/** Compare function of psF64 data.
+ *
+ *  @return int      an integer less than, equal to, or greater than zero if 
+ *                   the first argument is considered to be respectively greater 
+ *                   than, equal to, or lessg than the second. 
+ */
+int psCompareDescendingF64(const void* a, const void* b);
+
+
+
+/// @}
+
+#endif
Index: /trunk/psLib/src/sysUtils/psHash.d
===================================================================
--- /trunk/psLib/src/sysUtils/psHash.d	(revision 1110)
+++ /trunk/psLib/src/sysUtils/psHash.d	(revision 1111)
@@ -1,3 +1,3 @@
 psHash.o psHash.d : psHash.c psHash.h ../collections/psList.h \
-  ../collections/psVector.h ../collections/psType.h psMemory.h psString.h \
-  psTrace.h psAbort.h
+  ../collections/psCompare.h ../collections/psVector.h \
+  ../collections/psType.h psMemory.h psString.h psTrace.h psAbort.h
Index: /trunk/psLib/src/types/psList.c
===================================================================
--- /trunk/psLib/src/types/psList.c	(revision 1110)
+++ /trunk/psLib/src/types/psList.c	(revision 1111)
@@ -1,11 +1,11 @@
 /** @file psList.c
  *  @brief Support for doubly linked lists
- *  @ingroup DataContainers
+ *  @ingroup LinkedList
  *
  *  @author Robert Lupton, Princeton University
  *  @author Robert Daniel DeSonia, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-23 23:00:15 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-28 20:36:37 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -426,5 +426,4 @@
     arr->n = list->size;
 
-
     ptr = list->head;
     n = list->size;
@@ -459,2 +458,23 @@
     return list;
 }
+
+
+psList* psListSort(psList* list, psCompareFcn compare)
+{
+    psVector* vector;
+    if (list == NULL) {
+        return NULL;
+    }
+
+    // convert to indexable vector for use by qsort.
+    vector = psListToVector(list);
+    psFree(list);
+
+    qsort(vector->data.V, vector->n, sizeof(void*),
+          (int(*)(const void *, const void *))compare);
+
+    // convert back to linked list
+    list = psVectorToList(vector);
+
+    return list;
+}
Index: /trunk/psLib/src/types/psList.h
===================================================================
--- /trunk/psLib/src/types/psList.h	(revision 1110)
+++ /trunk/psLib/src/types/psList.h	(revision 1111)
@@ -10,6 +10,6 @@
  *  @ingroup LinkedList
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-23 23:00:15 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-28 20:36:37 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -18,4 +18,5 @@
 #include <pthread.h>                   // we need a mutex to make this stuff thread safe.
 
+#include "psCompare.h"
 #include "psVector.h"
 
@@ -181,5 +182,8 @@
 );
 
+psList* psListSort(psList* list, psCompareFcn compare);
+
 /// @} End of DataGroup Functions
 
 #endif
+
