Index: trunk/psModules/src/objects/pmSource.c
===================================================================
--- trunk/psModules/src/objects/pmSource.c	(revision 14950)
+++ trunk/psModules/src/objects/pmSource.c	(revision 15039)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-09-21 00:21:57 $
+ *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-09-27 03:35:29 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -87,4 +87,5 @@
     pmSource *source = (pmSource *) psAlloc(sizeof(pmSource));
     *(int *)&source->id = id++;
+    source->seq = -1;
     source->peak = NULL;
     source->pixels = NULL;
@@ -111,4 +112,8 @@
     source->skyErr = NAN;
     source->pixWeight = NAN;
+
+    source->psfProb = NAN;
+    source->crNsigma = NAN;
+    source->extNsigma = NAN;
 
     psTrace("psModules.objects", 5, "---- end ----\n");
@@ -930,2 +935,35 @@
     return NULL;
 }
+
+// sort by SN (descending)
+int pmSourceSortBySN (const void **a, const void **b)
+{
+    pmSource *A = *(pmSource **)a;
+    pmSource *B = *(pmSource **)b;
+
+    psF32 fA = (A->peak == NULL) ? 0 : A->peak->SN;
+    psF32 fB = (B->peak == NULL) ? 0 : B->peak->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 pmSourceSortByY (const void **a, const void **b)
+{
+    pmSource *A = *(pmSource **)a;
+    pmSource *B = *(pmSource **)b;
+
+    psF32 fA = (A->peak == NULL) ? 0 : A->peak->y;
+    psF32 fB = (B->peak == NULL) ? 0 : B->peak->y;
+
+    psF32 diff = fA - fB;
+    if (diff > FLT_EPSILON) return (+1);
+    if (diff < FLT_EPSILON) return (-1);
+    return (0);
+}
+
