Index: RowRecordsAggregate.java
===================================================================
RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java,v
retrieving revision 1.2
diff -r1.2 RowRecordsAggregate.java
62c62
< import java.util.HashMap;
---
> import java.util.TreeMap;
64a65
> import java.util.Comparator;
76c77
<     HashMap records  = null;
---
>     TreeMap records  = null;
80d80
< 
83c83
<         records = new HashMap();
---
>         records = new TreeMap(new RowRecordsComparator());
219c219,267
< }
---
>     
>     /**
>      * compares between two row records according to their row number
>      */
>     private class RowRecordsComparator implements Comparator
>     {
>         /**
>          * Object equality, implemented as object identity
>          * @param o Object we're being compared to
>          * @return true if identical, else false
>          */
>         public boolean equals(Object obj)
>         {
>             return this == obj;
>         }
>         
>         /**
>          * compare method. Checks if any of the parameters is null or not 
>          * instances of RowRecord. 
>          * One row is less than another if its row number is smaller than
>          * the other's. 
>          *
>          * @param row1 first object to compare, better be a RowRecord
>          * @param row2 second object to compare, better be a RowRecord
>          *
>          * @return negative value if row1 < row2,
>          *         zero           if row1 == row2,
>          *         positive value if row1 >  row2.
>          */      
>         public  int compare(Object row1, Object row2) {
>           //if any of the records is null, return not equal
>           if (row1 == null || row2 == null)
>             return -1;
>           //if any of the objects isn't a RowRecrod, return not equal
>           if (!(row2 instanceof RowRecord && row2 instanceof RowRecord))
>             return -1;
>           //get row numbers of both row records
>           int row1Number = ((RowRecord)row1).getRowNumber();
>           int row2Number = ((RowRecord)row2).getRowNumber();
>           //compare row numbers and return result
>           if (row1Number == row2Number)
>             return 0;
>           else if (row1Number < row2Number)
>             return -1;
>           else
>             return 1;
>         }    
>     }//end private class RowRecordsComparator  
> }
\ No newline at end of file

