A data sorting method and device for sorting parameters
By predicting the index value of the sorting parameters and storing them in the fragment, the problem of redundant comparison of massive data sorting in the prior art is solved, and a more efficient sorting process is achieved.
Patent Information
- Application Number
- CN202210180688.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-25
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2042-02-25
AI Technical Summary
When sorting massive data, there are multiple redundant comparison processes in the existing sorting method, which greatly increases the time overhead and reduces the performance and speed of sorting.
By obtaining the sorting parameters to be sorted, and establishing a result storage space that matches the total number of sorting parameters, determining the index values of all sorting parameters according to the preset prediction method and the number of slices, storing the sorting parameters with the same index value in a fragment, and writing the sorting parameters in the fragment into the prediction location of the result storage space according to the order of index values.
The redundant comparison process in determining the sorting position is reduced, the sorting speed is improved, and the time consumption caused by redundant comparison is reduced.
Smart Images

Figure CN114637745B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a data sorting technology for sorting parameters. Background Art
[0002] Data sorting methods have important applications in various fields such as data statistics, score ranking, strategy optimization, genetic algorithms, interface signatures, etc. In the era of big data, there is a need to sort massive amounts of data, so higher requirements are placed on the performance of sorting.
[0003] Most of the existing sorting methods are carried out by traversing multiple decreasing ranges and then making pairwise comparisons. Although the ways of decreasing ranges are different, there will inevitably be multiple redundant comparison processes. These redundant comparison operations greatly increase the time overhead for sorting massive amounts of data, reducing the performance and speed of sorting. Summary of the Invention
[0004] The purpose of this application is to provide a data sorting method and device for sorting parameters.
[0005] According to one aspect of this application, there is provided a data sorting method for sorting parameters, wherein the method includes:
[0006] a. Obtain the sorting parameters to be sorted and establish a result storage space that matches the total number of the sorting parameters, wherein the result storage space is used to sequentially store all the sorting parameters;
[0007] b. Determine the index values of all the sorting parameters according to a preset prediction method and the number of slices, wherein the index value represents the predicted position of the sorting parameter in the result storage space;
[0008] c. Store the sorting parameters with the same index value in a segment to generate multiple segments corresponding to the index values;
[0009] d. Sequentially write the sorting parameters in the segment corresponding to the index value into the predicted position in the result storage space corresponding to the index value according to the order of the index values.
[0010] Optionally, step d includes:
[0011] Traverse the segments corresponding to each index value according to the order of the index values. When the segment corresponding to the index value meets the preset result writing rule, write the sorting parameters in the segment corresponding to the index value into the predicted position in the result storage space corresponding to the index value.
[0012] Optionally, step d includes:
[0013] Traverse the segments corresponding to each index value in the order of the index values. When the segment does not conform to the preset result writing rule, update all the sorting parameters to the sorting parameters in this segment, and repeat steps b, c, and d.
[0014] Further, the writing of the sorting parameters in the segment corresponding to the index value to the predicted position in the result storage space corresponding to the index value includes:
[0015] Set a result storage mark with the initial value being the starting address of the result storage space;
[0016] Write all the sorting parameters in the segment corresponding to the index value into the result storage space sequentially starting from the result storage mark;
[0017] Move the result storage mark to the first unwritten address in the result storage space.
[0018] Further, when the result storage space is represented in the form of a result array, the method further includes:
[0019] Store the sorting parameters to be sorted in a to-be-sorted array;
[0020] Wherein, the establishment of the result storage space matching the total number of sorting parameters includes: establishing a result array with the array length equal to the total number of sorting parameters.
[0021] Preferably, step c further includes:
[0022] Set a slice array with the array length equal to the preset number of slices, wherein the slice array is a two-dimensional array;
[0023] Store the segments in the slice array in the form of an array in the order of their corresponding index values.
[0024] Further, the storing of the segments in the slice array in the form of an array in the order of their corresponding index values includes:
[0025] Store the segments in the form of an array in the slice array element whose array subscript is equal to the index value corresponding to the segment.
[0026] Further, the traversing of the segments corresponding to each index value according to the index value order includes:
[0027] Traverse each segment in the slice array in the order of the array subscript of the slice array.
[0028] Preferably, wherein the initial value of the result storage mark is the array element with the subscript 0 in the result array.
[0029] Further, moving the result storage marker to the first unwritten address in the result storage space includes:
[0030] Accumulate the array subscript corresponding to the result storage marker and the number of sorting parameter of the written segment, and use the result as the array subscript corresponding to the updated result storage marker.
[0031] Preferably, conforming to the preset result writing rule includes:
[0032] The total number of sorting parameters in the segment does not exceed 2.
[0033] Further, determining the index value corresponding to each sorting parameter in the array to be sorted in sequence according to the preset prediction method and the number of slices includes:
[0034] Obtain the maximum value maxvalue, the minimum value minvalue, the preset number of slices n and the sorting parameter value value of the array to be sorted, then the width step of the segment where the sorting parameter is located = (maxvalue - minvalue) / (n - 1);
[0035] Then the index value index of the sorting parameter = Math.floor((value - minvalue) / step).
[0036] According to another aspect of the present application, there is also provided a computer-readable medium, on which computer-readable instructions are stored, and the computer-readable instructions can be executed by a processor to implement the operations of the foregoing method.
[0037] According to still another aspect of the present application, there is also provided a data sorting device for sorting parameters, wherein the device includes:
[0038] One or more processors; and
[0039] A memory storing computer-readable instructions, and the computer-readable instructions, when executed, cause the processor to perform the operations of the above method.
[0040] Compared with the prior art, in this application, sorting parameters to be sorted are obtained, and a result storage space matching the total number of the sorting parameters is established, where the result storage space is used to sequentially store all the sorting parameters; index values of all the sorting parameters are determined according to a preset prediction method and the number of slices, where the index value represents the predicted position of the sorting parameter in the result storage space; the sorting parameters with the same index value are stored in a segment to generate multiple segments corresponding to the index value; and the sorting parameters in the segment corresponding to the index value are sequentially written into the predicted position of the result storage space corresponding to the index value according to the order of the index values. By this way, the approximate sorting positions of the sorting parameters are predicted, thereby reducing the redundant comparison process in the process of determining the sorting positions. Therefore, the sorting speed is improved, and the time consumption caused by redundant comparison in the sorting process is greatly reduced. Description of the Drawings
[0041] Other features, objects, and advantages of the present invention will become more apparent by reading the detailed description of the non-limiting embodiments with reference to the following drawings:
[0042] Figure 1 A flowchart of a data sorting method for sorting parameters according to an aspect of the present application is shown;
[0043] Figure 2 A flowchart of a data sorting method for sorting parameters according to a preferred embodiment of the present application is shown.
[0044] The same or similar reference numerals in the drawings represent the same or similar components. Detailed Description of the Embodiments
[0045] The present invention will be further described in detail below with reference to the drawings.
[0046] In a typical configuration of the present application, the terminal, the device of the service network, and the trusted party all include one or more processors (CPUs), an input / output interface, a network interface, and a memory.
[0047] The memory may include non-permanent memory in the computer-readable medium, random access memory (RAM), and / or non-volatile memory in the form of, for example, read-only memory (ROM) or flash memory (flash RAM). The memory is an example of the computer-readable medium.
[0048] A computer-readable medium includes permanent and non-permanent, removable and non-removable media and can implement information storage by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic disk storage or other magnetic storage devices, or any other non-transitory medium that can be used to store information accessible by a computing device. As defined herein, a computer-readable medium does not include transitory media such as modulated data signals and carrier waves.
[0049] To further elaborate on the technical means and achieved effects adopted in this application, the technical solution of this application will be clearly and completely described below in conjunction with the accompanying drawings and preferred embodiments.
[0050] Figure 1 A data sorting method for sorting parameters provided in one aspect of this application is shown, where the method includes:
[0051] S11 Obtain the sorting parameters to be sorted and establish a result storage space that matches the total number of the sorting parameters, where the result storage space is used to sequentially store all the sorting parameters;
[0052] S12 Determine the index values of all the sorting parameters according to a preset prediction method and the number of slices, where the index value represents the predicted position of the sorting parameter in the result storage space;
[0053] S13 Store the sorting parameters with the same index value in a segment to generate multiple segments corresponding to the index values;
[0054] S14 Sequentially write the sorting parameters in the segment corresponding to the index value to the predicted position in the result storage space corresponding to the index value according to the order of the index values.
[0055] The data sorting method for sorting parameters provided by this application can be used in fields such as massive data statistics. Specifically, it can be applied to the statistical sorting of all alarm logs in the e-government cloud. The e-government cloud combines the characteristics of cloud computing technology, streamlines, optimizes, and integrates the government's management and service functions, and realizes various business process handling and function services in government affairs through information technology means, providing a reliable basic IT service platform for government departments at all levels. And the alarm log, as an important record of system behavior, contains all internal error information, block damage information, deadlock error information, database operations, data file operations, tablespace operations, process scheduling information, materialized view errors, parameter modification information, etc. in the system. And in the e-government cloud environment, information such as alarm level, alarm status, monitoring object, resource type, cloud account, affiliated organization, and alarm time can be custom-set to achieve full operation records of the alarm log for the e-government cloud environment. And in this process, statistical sorting of the alarm log is an important prerequisite for realizing links such as database maintenance and network security maintenance.
[0056] Here, it should be clear that the data sorting method for sorting parameters provided by this application can also be used in specific fields such as grade ranking, strategy optimization, genetic algorithm optimization, and interface signature. This application does not make restrictive descriptions of the specific application scenarios. All application scenarios that can apply the method described in this application are within the protection scope of this application.
[0057] Taking the statistical sorting of all alarm logs in the e-government cloud as an example, the alarm log has field information such as "message content", "alarm level", "alarm status", "monitoring object", "resource type", "cloud account", "affiliated organization", and "alarm time". Users can select the fields to be sorted. Taking sorting by "alarm time" as an example, convert the "alarm time" into a sorting parameter that can be compared in size, sort the sorting parameter according to the method described below, then convert the sorted sorting parameter in order into "alarm time", and finally summarize and display the sorting order of "alarm time" as the display order of the alarm log.
[0058] In this method, S11 obtains the sorting parameter to be sorted and establishes a result storage space that matches the total number of the sorting parameters. Among them, the result storage space is used to sequentially store all sorting parameters.
[0059] Here, the result storage space can adopt data storage methods such as arrays, dynamic arrays, linked lists, and blockchains. Preferably, the space size of the result storage space is equal to the space size required to store all sorting parameters, so as to save the space required to store the sorting parameters and reduce space consumption.
[0060] Preferably, when the result storage space is represented in the form of a result array, the method further includes: storing the sorting parameters to be sorted in an array to be sorted; wherein, establishing the result storage space matching the total number of sorting parameters includes: establishing a result array with an array length equal to the total number of sorting parameters.
[0061] Here, the result storage space adopts an array storage method. Correspondingly, after obtaining the sorting parameters, they are summarized and stored in the array to be sorted. By this way, the data storage methods before and after sorting are unified, which is convenient for specific operations such as data transfer in data sorting and simplifies the sorting process.
[0062] Continuing in this method, S12 determines the index values of all sorting parameters according to a preset prediction method and the number of slices, where the index value represents the predicted position of the sorting parameter in the result storage space.
[0063] Here, the index values of each sorting parameter are calculated through a preset prediction method and the number of slices. The index value represents the approximate position of the sorting parameter in the sequential sequence. For example, when the index value of the sorting parameter calculated through the prediction method is 3, it means that the sorting parameter is approximately in the 3rd position in the sequential (descending or ascending) sequence of all sorting parameters. By this way, the positions of each sorting parameter in the sequential sorting are predicted, thereby greatly reducing the number of comparisons in the sorting process and achieving that the position where the sorting parameter should be located can be determined through very few comparisons.
[0064] Further, the sequentially determining the index values of all sorting parameters according to a preset prediction method and the number of slices includes: obtaining the maximum value maxvalue, the minimum value minvalue, the preset number of slices n, and the value value of the sorting parameter in the sorting parameters. Then the width step of the segment where the sorting parameter is located is step = (maxvalue - minvalue) / (n - 1); and the index value index of the sorting parameter is index = Math.floor((value - minvalue) / step).
[0065] Continuing in this method, S13 stores the sorting parameters with the same index value in one segment to generate multiple segments corresponding to the index values.
[0066] Here, sorting parameters with the same index value have similar values, and their approximate positions in the sequence (descending or ascending order) of all sorting parameters are close. Such sorting parameters are integrated as a segment. In this way, the entire value space of the sorting parameters is sliced and decomposed into multiple segments with similar values. This method adopts the divide-and-conquer approach, decomposing the sorting problem of the entire value space of the sorting parameters into sorting sub-problems of fewer sorting parameters in multiple small intervals, greatly reducing the complexity of sorting.
[0067] At the same time, the divide-and-conquer method adopted by the existing sorting methods directly divides the unordered original data sequence, and the data in each divided subsequence has no correlation in value. However, the divide-and-conquer method adopted by this application slices the entire value space of the sorting parameters in order through the prediction of the sorting position, and the sorting parameter values in each segment are similar. Therefore, sorting each segment in this way has lower complexity and less time consumption compared to the ordinary divide-and-conquer method.
[0068] Further, when the result storage space and all sorting parameters adopt the array storage method, correspondingly, a slice array with the array length equal to the preset number of slices is set, where the slice array is a two-dimensional array; the segments are stored in the slice array in the form of an array according to the order of their corresponding index values.
[0069] Here, the segment stores sorting parameters with the same index value in the form of an array and stores each segment in the slice array. Therefore, the slice array is a two-dimensional array and its length is equal to the preset number of slices. In this way, the data storage method is unified, which is convenient for specific operations such as data transfer in data sorting and simplifies the sorting process. At the same time, the length of the slice array is equal to the preset number of slices, reducing the waste of storage space.
[0070] Further, the storing the segments in the slice array in the form of an array according to the order of their corresponding index values includes: storing the segments in the slice array element whose array subscript is equal to the index value corresponding to the segment.
[0071] Here, since the subscript of the slice array represents the position of the segment in the slice array, and the index value of the segment also represents the position of the segment in the slice array, directly storing the segment in the slice array element whose array subscript is equal to the index value corresponding to the segment realizes the sequential storage of the segments in the slice array. For example, when the index value of the segment is 0, the segment is stored in the array element with the slice array subscript of 0 (i.e., the first element), and when the index value of the segment is 1, the segment is stored in the array element with the slice array subscript of 1 (i.e., the second element), and so on.
[0072] Further, the step of sequentially determining the index value corresponding to each sorting parameter in the array to be sorted according to a preset prediction method and the number of slices includes: obtaining the maximum value maxvalue, the minimum value minvalue, the preset number of slices n, and the sorting parameter value value in the array to be sorted. Then, the width step of the segment where the sorting parameter is located is (maxvalue - minvalue) / (n - 1); and the index value index of the sorting parameter is Math.floor((value - minvalue) / step).
[0073] Here, according to this calculation method, the index value of the maximum sorting parameter is n - 1, and the index value of the minimum sorting parameter is 0. That is, the value range of the index value is the closed interval from 0 to n - 1, which is equal to the array length of the slice array, ensuring the one-to-one correspondence between the segments and the elements of the slice array.
[0074] Continuing with this method, in S14, the sorting parameters in the segment corresponding to the index value are sequentially written into the predicted position of the result storage space corresponding to the index value according to the order of the index values.
[0075] Here, the sorting parameters in the segments are sequentially written in the order of the index values (ascending or descending), and the writing position is determined by the index value of the sorting parameter. Since the index value of each segment represents the approximate position of the segment in the sequential sorting, writing the segments in the order of the index values ensures that the segments are written in ascending or descending order. For the result storage space, the writing operation is performed sequentially at consecutive addresses. This consecutive address writing avoids the existence of unwritten empty positions between two sorting parameters in the result storage space, ensures that the size of the result storage space is equal to the space required to store all sorting parameters, avoids space waste, and at the same time ensures the accuracy of the writing order.
[0076] Taking ascending sorting as an example, the segments corresponding to the index values are sequentially obtained in ascending order of the index values. In the optimal case, after one slicing, there is only 1 sorting parameter in each segment. In this case, the sorting parameter in the segment is directly written into the predicted position of the result storage space represented by its index value.
[0077] Further, the result storage space is a result array. When there is only 1 sorting parameter in each segment, the sorting parameters in the segments are sequentially written into the result array elements whose array subscripts are equal to the index values according to the order of the segment index values (ascending or descending). For example, if the index value of the segment is 0, the sorting parameter in the segment is written into the result array element with the array subscript 0; if the index value of the segment is 1, the sorting parameter in the segment is written into the result array element with the array subscript 1, and so on.
[0078] Specifically, when all sorting parameters are evenly distributed at equal intervals throughout the value range, the number of slices can be directly set to the quotient of the length of the value range and the length of the interval, so that there is only 1 sorting parameter in each segment. Taking the entire data with a value range of 50 to 100 for the sorting parameter and an interval of 0.5 as an example, setting the number of slices to 100 can ensure that there is only 1 sorting parameter in each segment. In this case, each segment is directly written to the predicted position represented by the index value in the order of its corresponding index value, that is, the task of data sorting is completed through one calculation.
[0079] Further, when the segments are stored in the form of an array in the slice array element whose array subscript is equal to the index value corresponding to the segment, the traversing of the segments corresponding to each index value according to the order of the index values includes: traversing each segment in the slice array in the order of the array subscript of the slice array.
[0080] Here, since the index value of the segment is its corresponding array subscript and is stored in the slice array in this order, when traversing each segment in order, it can be done in the order of the slice array subscript.
[0081] Further, the compliance with the preset result writing rule includes: the total number of sorting parameters in the segment does not exceed 2.
[0082] Here, only the segments with the number of sorting parameters not exceeding 2 are written. When the number of sorting parameters in the segment is 1, the sorting parameter is directly written; when the number of sorting parameters in the segment is 2, only one comparison is needed to write the sorting parameters in the segment to the result storage space according to the comparison result. When the number of sorting parameters in the written segment is limited not to exceed 2, the operational complexity of data comparison is greatly reduced.
[0083] Further, the writing of the sorting parameter in the segment corresponding to the index value to the predicted position of the result storage space corresponding to the index value includes: setting a result storage mark with the initial value being the start address of the result storage space; sequentially writing all the sorting parameters in the segment corresponding to the index value to the result storage space starting from the result storage mark; and moving the result storage mark to the first unwritten address in the result storage space.
[0084] Here, the set result storage marker is used to mark the write position in the result storage space. The initial value of the result storage marker is set to the start address of the result storage space, ensuring that the sequential write operation starts from the start address of the result storage space. At the same time, after each fragment is written, the result storage marker is moved to the first unwritten position, ensuring that the write operation is carried out sequentially according to consecutive addresses, that is, it avoids the existence of unwritten empty positions between two sorting parameters in the result storage space, ensures that the size of the result storage space is equal to the space required to store all sorting parameters, avoids space waste, and at the same time ensures the accuracy of the write order.
[0085] Further, when the result storage space is in the form of an array, the initial value of the result storage marker is the array element with subscript 0 in the result array. In this way, the first write position can be determined as the first element of the result array, thus realizing sequential writing in the result array.
[0086] Correspondingly, moving the result storage marker to the first unwritten address in the result storage space includes: adding the array subscript corresponding to the result storage marker to the number of sorting parameters of the written fragment, and using the result as the array subscript corresponding to the updated result storage marker.
[0087] Here, after a fragment starts writing the sorting parameters it contains from the result storage marker, the result storage marker is correspondingly moved to the end of the write position of this fragment. Since one array subscript can represent one write position, therefore, adding the current array subscript corresponding to the result storage marker to the total number of sorting parameters of this fragment, and updating the array subscript corresponding to the result storage marker to this sum value, that is, realizing the movement of the result storage marker.
[0088] In a preferred embodiment, refer to Figure 2 as shown, where Figure 2 Steps S21, S22, and S23 in Figure 1 are the same as or substantially the same as steps S11, S12, and S13 in the
[0089] embodiment, so they will not be elaborated here and are only included herein by reference. Among them, the step S24 is:
[0090] Here, according to the result writing rule, it is judged in turn whether each segment can be directly written into the result storage space. When the segment can be directly written into the result storage space, the sorting parameter in the segment is directly written into the predicted position in the result storage space corresponding to its index value.
[0091] When the segment traversed in the order of the index value does not conform to the result writing rule, the segment is recursively sliced. The segment is divided into multiple sub-segments according to the prediction method and the number of slices, and then it is judged in turn according to the result writing rule whether each sub-segment can be directly written into the result storage space, and the recursion is repeated until all the sorting parameters in the segment are written. By means of recursive slicing, a segment that cannot be directly written is split into multiple sub-segments that can be directly written, avoiding the overall sorting of all sorting parameters in the segment, greatly reducing the number of data comparisons and the complexity of the problem, and improving the sorting speed.
[0092] Compared with the prior art, the present application obtains the sorting parameters to be sorted and establishes a result storage space matching the total number of the sorting parameters, wherein the result storage space is used to sequentially store all the sorting parameters; determines the index values of all the sorting parameters according to a preset prediction method and the number of slices, wherein the index value represents the predicted position of the sorting parameter in the result storage space; stores the sorting parameters with the same index value in one segment to generate multiple segments corresponding to the index value; and writes the sorting parameters in the segment corresponding to the index value into the predicted position in the result storage space corresponding to the index value in turn according to the index value order. By this method, the approximate sorting positions of the sorting parameters are predicted, thereby reducing the redundant comparison process in the process of determining the sorting positions. Therefore, the sorting speed is improved, and the time consumption caused by redundant comparison in the sorting process is greatly reduced.
[0093] In addition, an embodiment of the present application further provides a computer-readable medium, on which computer-readable instructions are stored, and the computer-readable instructions can be executed by a processor to implement the foregoing method.
[0094] An embodiment of the present application further provides a data sorting device for sorting parameters, wherein the device includes:
[0095] One or more processors; and
[0096] A memory storing computer-readable instructions, and the computer-readable instructions, when executed, cause the processor to perform the operations of the foregoing method.
[0097] For example, when the computer-readable instructions are executed, the one or more processors are caused to:
[0098] a Obtain the sorting parameters to be sorted, and establish a result storage space that matches the total number of the sorting parameters, wherein the result storage space is used to sequentially store all the sorting parameters;
[0099] b Determine the index values of all the sorting parameters according to a preset prediction method and the number of slices, wherein the index value represents the predicted position of the sorting parameter in the result storage space;
[0100] c Store the sorting parameters with the same index value in a segment to generate multiple segments corresponding to the index values;
[0101] d Sequentially write the sorting parameters in the segment corresponding to the index value to the predicted position in the result storage space corresponding to the index value according to the index value.
[0102] For those skilled in the art, it is obvious that the present invention is not limited to the details of the above exemplary embodiments, and the present invention can be implemented in other specific forms without departing from the spirit or basic characteristics of the present invention. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-limiting. The scope of the present invention is defined by the appended claims rather than the above description. Therefore, all changes falling within the meaning and scope of the equivalent elements of the claims are intended to be included in the present invention. Any reference signs in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. The multiple units or devices stated in the device claims can also be implemented by one unit or device through software or hardware. First, second, etc. are used to indicate names and do not represent any specific order.
Claims
1. A data sorting method for sorting parameters, wherein, The method includes: a. Obtain sorting parameters to be sorted, and establish a result storage space that matches the total number of sorting parameters, where the result storage space is used to sequentially store all sorting parameters; b. Determine the index values of all sorting parameters according to a preset prediction method and the number of slices, where the index value represents the predicted position of the sorting parameter in the result storage space; c. Store the sorting parameters with the same index value in one segment to generate multiple segments corresponding to the index values; d. Sequentially write the sorting parameters in the segment corresponding to the index value to the predicted position in the result storage space corresponding to the index value according to the order of the index values; Wherein, the writing the sorting parameters in the segment corresponding to the index value to the predicted position in the result storage space corresponding to the index value includes: Set a result storage marker with the initial value being the start address of the result storage space; Sequentially write all sorting parameters in the segment corresponding to the index value into the result storage space starting from the result storage marker; Move the result storage marker to the first unwritten address in the result storage space.
2. The method according to claim 1, wherein, The step d includes: Traverse the segments corresponding to each index value according to the order of the index values. When the segment corresponding to the index value meets the preset result writing rule, write the sorting parameters in the segment corresponding to the index value to the predicted position in the result storage space corresponding to the index value.
3. The method according to claim 1, wherein, The step d includes: Traverse the segments corresponding to each index value according to the order of the index values. When the segment does not meet the preset result writing rule, update all sorting parameters to the sorting parameters in the segment, and repeat steps b, c, and d.
4. The method according to claim 1, wherein When the result storage space is represented in the form of a result array, the method further includes: Store the sorting parameters to be sorted in an array to be sorted; Wherein, the establishing a result storage space that matches the total number of sorting parameters includes: establishing a result array with the array length equal to the total number of sorting parameters.
5. The method according to claim 4, wherein The step c further includes: Set a slice array with the array length equal to the preset number of slices, where the slice array is a two-dimensional array; Store the segments in the slice array in the form of an array according to the order of their corresponding index values.
6. The method according to claim 5, wherein, The storing the segments in the slice array in the form of an array according to the order of their corresponding index values includes: Store the segments in the form of an array in the slice array element whose array subscript is equal to the index value corresponding to the segment.
7. The method according to claim 6, wherein The traversing the segments corresponding to each index value according to the order of the index values includes: Traverse each segment in the slice array according to the order of the array subscripts of the slice array.
8. The method according to any one of claims 4 to 7, wherein, The initial value of the result storage marker is the array element with the subscript 0 in the result array.
9. The method according to claim 8, wherein The moving the result storage marker to the first unwritten address in the result storage space includes: Accumulate the array subscript corresponding to the result storage marker and the number of sorting parameters of the written segment, and use the result as the updated array subscript corresponding to the result storage marker.
10. The method according to claim 2, wherein The meeting the preset result writing rule includes: The total number of sorting parameters in the segment does not exceed 2.
11. The method according to any one of claims 5 to 7, wherein, Determining the index values corresponding to the respective sorting parameters in the array to be sorted in sequence according to the preset prediction method and the number of slices includes: Obtaining the maximum value maxvalue, the minimum value minvalue, the preset number of slices n, and the sorting parameter value value of the array to be sorted, then the width step of the segment where the sorting parameter is located = (maxvalue - minvalue) / (n - 1); Then the index value index of the sorting parameter = Math.floor((value - minvalue) / step).
12. A computer-readable medium having computer-readable instructions stored thereon, the computer-readable instructions being executed by a processor to implement the method according to any one of claims 1 to 11.
13. A data sorting device for sorting parameters, wherein, The apparatus includes: One or more processors; and A memory storing computer-readable instructions, the computer-readable instructions when executed causing the processor to perform the operations of the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Object sorting method and device
CN108052309A