CPC G06F 7/24 (2013.01) [G06F 16/9024 (2019.01)] | 16 Claims |
1. A computer implemented method for sorting an array comprised of a plurality of elements, the method comprising the steps of:
receiving a sort request from a requesting user that includes one or more sorting criteria for the array comprised of a plurality of elements, wherein the elements are stored in memory that is accessible by a computer processor and wherein the elements are comprised of one or more bits that may be active or inactive;
instructing the processor to run a sorting algorithm to sort the elements from a first order to a second order wherein the second order is a sorted array, wherein the elements are sorted dependent on the sorting criteria and the sorting of the elements is performed by examining binary encoding of the elements;
running the sorting algorithm to sort the array of elements in a memory, wherein the sorting algorithm comprises the steps of:
creating a plurality of swap-indices equal to the square of the number of bits to be counted with each swap-index being associated with one configuration of bits;
moving the plurality of swap indices sequentially through each element, and stopping each swap-index at any element with a configuration of bits that is different from that of the swap-index:
move the element on which a swap-index stopped to the position in the array occupied by its current proper swap-index, the swap-index with a matching bit configuration;
setting a pointer to a value equal to the value of a highest bit encoded for each element;
moving the pointer in sequence through the array and examining a bit in each element of an order equal to the current value of the pointer until encountering an element where the current bit is active;
creating a new sub-array, if one has not already been created for the current pointer value;
moving each element encountered by the pointer with the active hit of an order equal to the value of the pointer to a beginning of the new sub-array;
continuing through the array elements and moving each element encountered where the first bit is active to the end of the new sub-array.
|