Bug 322512 Refactor data set editor pages' codes[30357]
Build Identifier: Refactor data set editor pages' codes. Reproducible: Always
UI/org.eclipse.birt.report.designer.ui.data/src/org/eclipse/birt/report/designer/data/ui/dataset/ResultSetPreviewPage.java
}
	/**
	 * Carry out sort operation against certain column
	 * 
	 * @param columnIndex
	 *            the column based on which the sort operation would be carried
	 *            out
	 * @param asc
	 *            the sort direction
	 */
	private void sort( final int columnIndex, final boolean asc )
	{
		resultSetTable.setSortColumn( resultSetTable.getColumn( columnIndex ) );
		resultSetTable.setSortDirection( asc == true ? SWT.DOWN : SWT.UP );
		this.resultSetTableViewer.setSorter( new ViewerSorter( ) {
			
			public int compare( Viewer viewer, Object e1, Object e2 )
			{
				CellValue cv1 = ( (CellValue[]) e1 )[columnIndex];
				CellValue cv2 = ( (CellValue[]) e2 )[columnIndex];
				int result = 0;
				if ( cv1 == null && cv1 != cv2 )
					result = -1;
				else if ( cv1 != null )
					result = cv1.compareTo( cv2 );
				if ( !asc )
					return result;
				else
					return result * -1;
			}