Index: trunk/psModules/src/objects/pmPeaks.c
===================================================================
--- trunk/psModules/src/objects/pmPeaks.c	(revision 14652)
+++ trunk/psModules/src/objects/pmPeaks.c	(revision 15039)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-08-24 00:11:02 $
+ *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-09-27 03:35:29 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -51,4 +51,5 @@
 
     // calculate peak position relative to ix,iy
+    // XXX these functions need to take a mask, weight, and calculate the errors
     psPolynomial2D *bicube = psImageBicubeFit (image, ix + image->col0, iy + image->row0);
     psPlane min = psImageBicubeMin (bicube);
@@ -59,7 +60,11 @@
         peak->xf = min.x + ix + image->col0;
         peak->yf = min.y + iy + image->row0;
+	peak->dx = 0.0;
+	peak->dy = 0.0;
     } else {
         peak->xf = ix;
         peak->yf = iy;
+	peak->dx = 1.0;
+	peak->dy = 1.0;
     }
 
@@ -189,4 +194,36 @@
     }
     psTrace("psModules.objects", 3, "---- %s(0) end ----\n", __func__);
+    return (0);
+}
+
+// sort by SN (descending)
+int pmPeakSortBySN (const void **a, const void **b)
+{
+    pmPeak *A = *(pmPeak **)a;
+    pmPeak *B = *(pmPeak **)b;
+
+    psF32 fA = A->SN;
+    psF32 fB = B->SN;
+    if (isnan (fA)) fA = 0;
+    if (isnan (fB)) fB = 0;
+
+    psF32 diff = fA - fB;
+    if (diff > FLT_EPSILON) return (-1);
+    if (diff < FLT_EPSILON) return (+1);
+    return (0);
+}
+
+// sort by Y (ascending)
+int pmPeakSortByY (const void **a, const void **b)
+{
+    pmPeak *A = *(pmPeak **)a;
+    pmPeak *B = *(pmPeak **)b;
+
+    psF32 fA = A->y;
+    psF32 fB = B->y;
+
+    psF32 diff = fA - fB;
+    if (diff > FLT_EPSILON) return (+1);
+    if (diff < FLT_EPSILON) return (-1);
     return (0);
 }
