3.2.2.1 Sortmap Elements

This subclause specifies the elements and simple types that comprise the Sort Map.

A sort map is used in the context of a shared workbook to record the sort order of a range of cells. This information is used to correctly update cells and formulas that depend on the sort order when revision information is applied. There is one sort map per worksheet.

The sort map consists of two components:  The row sort map and the column sort map. The row sort map contains a list of row indices that need to be adjusted when revision information is applied. The row sort map is created when a range of cells is sorted top down or bottom up. The column sort map contains a list of column indices that need to be adjusted when revision information is applied. The column sort map is created when a range of cells is sorted left to right or right to left.

[Example: Consider the following shared workbook:

Table showing 4 unsorted rows of data in one column. Cell A2 contains number 5, A3 contains number 6, A4 contains number 7, A5 contains number 8

The worksheet contains four rows of data. Once the data is sorted in descending order, the worksheet looks as follows:

Table with 4 rows of data in one column sorted descending. Cell A2 contains number 8, cell A3 contains number 7, cell A4 contains num er 6, cell A6 contains number 5

When this worksheet is saved, the following sort map should be created and saved to the file:

 <worksheetSortMap xmlns="http://schemas.microsoft.com/office/excel/2006/main">
    <rowSortMap ref="A2:XFD5" count="4">
       <row newVal="1" oldVal="4"/>
       <row newVal="2" oldVal="3"/>
       <row newVal="3" oldVal="2"/>
       <row newVal="4" oldVal="1"/>
    </rowSortMap>
 </worksheetSortMap>

In the context of this example, the sort map implies that the contents of the second row should be replaced with the contents of the fifth row; contents of the third row should be replaced with the contents of the fourth row; and so on.

Now consider the following worksheet:

Table with 4 columns of data in one row. Cell A2 contains number 5, cell B2 contains number 6, cell C3 contains number 7, cell D2 contains number 8

This worksheet contains four columns of data. Once the data is sorted left to right in descending order, the worksheet looks as follows:

Table with 4 columns of data in one row sorted descending. Cell A2 contains number 8, cell B2 contains number 7, cell C2 contains number 6, cell D2 contains number 5

When this worksheet is saved, the following sort map should be created and saved to the file:

 <worksheetSortMap xmlns="http://schemas.microsoft.com/office/excel/2006/main">
    <colSortMap ref="A1:D1048576" count="4">
       <col newVal="0" oldVal="3"/>
       <col newVal="1" oldVal="2"/>
       <col newVal="2" oldVal="1"/>
       <col newVal="3" oldVal="0"/>
    </colSortMap>
 </worksheetSortMap>

In the context of this example, the sort map implies that the contents of the first column should be replaced with the contents of the fourth column; contents of the second column should be replaced with the contents of the third column; and so on.

End Example]