1. A method for sorting a table of a database according to a sort pattern and a sort order, comprising: allocating space for a sorted table, the space allocated in memory or storage; determining an offset value for each sort pattern in the table of the database, the offset value determined as a function of the sort order and a number of instances for each sort pattern; and forming the sorted table by copying each row of the table of the database to the allocated space, a position of the row in the sorted table determined as a function of the sort pattern of the row and the offset value for the sort pattern of the row, wherein the offset value for the sort pattern of the row is incremented after copying the row.