Data sorting method, device and electronic equipment
By creating a sorting control table to record data identifiers and preset sorting position influence factors, and generating intra-segment sorting position description information, the problem of low data sorting efficiency in existing technologies is solved, and efficient local data sorting is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA TELECOM CORP LTD
- Filing Date
- 2022-12-20
- Publication Date
- 2026-06-23
Smart Images

Figure CN116166720B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to data sorting methods, apparatus, electronic devices, and computer-readable storage media. Background Technology
[0002] Outputting or displaying data sorted according to certain rules based on data stored in a database is a common database application requirement. To meet this need, common database applications typically provide basic filtering and sorting methods, such as calculating filter conditions based on matching a specific field for each data entry, or arranging data in order of value or character size according to a specific field. For example, in SQL, the following statement can be used to filter, sort, and sort data: `SELECT [field1], [field2],… FROM [table_name] WHERE [filter_condition] ORDER BY [sort_field1], [sort_field2],…`. This statement filters data based on the [filter_condition] value calculated using similarity matching of specified fields, and sorts the filtered data according to the value or character order of the specified sorting field.
[0003] Existing methods for sorting already sorted data require sorting the entire table when adjusting the sorting of only a portion of the data, resulting in low sorting efficiency. Summary of the Invention
[0004] This application provides a data sorting method, apparatus, and electronic device to solve the problem of low sorting efficiency in existing data sorting methods.
[0005] In a first aspect, embodiments of this application disclose a data sorting method, the method comprising:
[0006] In response to a change in the sorting position of the target data in the data source table, the record identifier and segment sorting number of the target data in the data source table are obtained, as well as the value of the preset sorting position influence factor of the target data.
[0007] Update the pre-created sorting control table based on the values of the record identifier, the segment sort number, and the preset sorting position influence factor;
[0008] Based on the updated sorting control table, generate intra-segment sorting position description information;
[0009] Based on the sorting position description information within the segment, the data in the data source table is sorted and output.
[0010] Optionally, updating the pre-created sorting control table based on the values of the record identifier, the segment sort number, and the preset sorting position influence factor includes any one of the following operations:
[0011] Delete the entry corresponding to the record identifier from the sorting control table;
[0012] In response to the fact that the record identifier is not recorded in the sorting control table, an entry corresponding to the record identifier is added to the sorting control table according to the value of the preset sorting position influence factor;
[0013] In response to the fact that the record identifier has been recorded in the sorting control table, the table entry corresponding to the record identifier recorded in the sorting control table is updated according to the value of the preset sorting position influence factor;
[0014] The table entries include: the record identifier, the segment sort number, and the value of the preset sort position influence factor.
[0015] Optionally, generating intra-segment sorting position description information based on the updated sorting control table includes:
[0016] Based on the value of the preset sorting position influence factor corresponding to each record identifier in the updated sorting control table, obtain the intra-segment sorting position control information corresponding to each record identifier;
[0017] Based on the segment sorting number and the sorting position control information within the segment, each item in the sorting control table is sorted from beginning to end, so that the item corresponding to the record identifier that is first in the output position is arranged at the beginning of the sorting control table.
[0018] Traverse each entry of the sorting control table from the beginning to the end of the table to obtain the sorting order of each record identifier, and the sorting position interval between two adjacent record identifiers with the same segment sorting number.
[0019] Based on the sorting order of the record identifiers and the sorting position interval between two adjacent record identifiers, a pre-formatted description text is generated as the intra-segment sorting position description information.
[0020] Optionally, generating a description text in a preset format based on the sorting order of the record identifiers and the sorting position interval between two adjacent record identifiers includes:
[0021] The record identifiers arranged in the sorting order are separated by a preset separator, and a preset number of placeholders matching the sorting position interval are inserted between the corresponding two record identifiers according to the sorting position interval between two adjacent record identifiers to generate a description text in a preset format.
[0022] Optionally, sorting and outputting the data in the data source table according to the sorting position description information within the segment includes:
[0023] For the data to be sorted in the data source table, the segment sort number of the data is obtained through the data source table, and the intra-segment sort number of the data is obtained through the intra-segment sort position description information.
[0024] The data is sorted and output based on the obtained segment sort number and the intra-segment sort number.
[0025] Optionally, obtaining the intra-segment sort number of the data through the intra-segment sort position description information includes:
[0026] Check whether the record identifier of the data is included in the sorting position description information within the segment;
[0027] In response to the inclusion of the record identifier in the intra-segment sorting position description information, the position number of the record identifier in the intra-segment sorting position description information is obtained through a preset character query instruction, and the intra-segment sorting number of the data is obtained based on the position number;
[0028] In response to the fact that the record identifier is not included in the intra-segment sorting position description information, the intra-segment sorting number of the data is set to the specified sorting number.
[0029] Secondly, embodiments of this application disclose a data sorting apparatus, the apparatus comprising:
[0030] The sorting information acquisition module is used to acquire the record identifier and segment sort number of the target data in the data source table, as well as the value of the preset sorting position influence factor of the target data, in response to a change in the sorting position of the target data in the data source table.
[0031] The sorting control table update module is used to update the pre-created sorting control table according to the values of the record identifier, the segment sort number and the preset sorting position influence factor.
[0032] The segment sorting position description information generation module is used to generate segment sorting position description information based on the updated sorting control table.
[0033] The sorting output module is used to sort and output the data in the data source table according to the sorting position description information within the segment.
[0034] Optionally, the sorting control table update module is further configured to perform any of the following operations:
[0035] Delete the entry corresponding to the record identifier from the sorting control table;
[0036] In response to the fact that the record identifier is not recorded in the sorting control table, an entry corresponding to the record identifier is added to the sorting control table according to the value of the preset sorting position influence factor;
[0037] In response to the fact that the record identifier has been recorded in the sorting control table, the table entry corresponding to the record identifier recorded in the sorting control table is updated according to the value of the preset sorting position influence factor;
[0038] The table entries include: the record identifier, the segment sort number, and the value of the preset sort position influence factor.
[0039] Optionally, generating intra-segment sorting position description information based on the updated sorting control table includes:
[0040] Based on the value of the preset sorting position influence factor corresponding to each record identifier in the updated sorting control table, obtain the intra-segment sorting position control information corresponding to each record identifier;
[0041] Based on the segment sorting number and the sorting position control information within the segment, each item in the sorting control table is sorted from beginning to end, so that the item corresponding to the record identifier that is first in the output position is arranged at the beginning of the sorting control table.
[0042] Traverse each entry of the sorting control table from the beginning to the end of the table to obtain the sorting order of each record identifier, and the sorting position interval between two adjacent record identifiers with the same segment sorting number.
[0043] Based on the sorting order of the record identifiers and the sorting position interval between two adjacent record identifiers, a pre-formatted description text is generated as the intra-segment sorting position description information.
[0044] Optionally, generating a description text in a preset format based on the sorting order of the record identifiers and the sorting position interval between two adjacent record identifiers includes:
[0045] The record identifiers arranged in the sorting order are separated by a preset separator, and a preset number of placeholders matching the sorting position interval are inserted between the corresponding two record identifiers according to the sorting position interval between two adjacent record identifiers to generate a description text in a preset format.
[0046] Optionally, the sorting output module is further configured to:
[0047] For the data to be sorted in the data source table, the segment sort number of the data is obtained through the data source table, and the intra-segment sort number of the data is obtained through the intra-segment sort position description information.
[0048] The data is sorted and output based on the obtained segment sort number and the intra-segment sort number.
[0049] Optionally, obtaining the intra-segment sort number of the data through the intra-segment sort position description information includes:
[0050] Check whether the record identifier of the data is included in the sorting position description information within the segment;
[0051] In response to the inclusion of the record identifier in the intra-segment sorting position description information, the position number of the record identifier in the intra-segment sorting position description information is obtained through a preset character query instruction, and the intra-segment sorting number of the data is obtained based on the position number;
[0052] In response to the fact that the record identifier is not included in the intra-segment sorting position description information, the intra-segment sorting number of the data is set to the specified sorting number.
[0053] Thirdly, embodiments of this application also disclose an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the data sorting method described in embodiments of this application.
[0054] Fourthly, embodiments of this application disclose a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, contains the steps of the data sorting method disclosed in embodiments of this application.
[0055] The data sorting method disclosed in this application, in response to a change in the sorting position of target data in a data source table, obtains the record identifier and segment sorting number of the target data in the data source table, as well as the value of the preset sorting position influence factor of the target data; updates a pre-created sorting control table based on the record identifier, the segment sorting number, and the value of the preset sorting position influence factor; generates intra-segment sorting position description information based on the updated sorting control table; and sorts and outputs the data in the data source table based on the intra-segment sorting position description information. This method eliminates the need to traverse the data source table; it only requires calculations on the sorting control table to adjust the sorting position of local data, reducing computational load and improving sorting efficiency.
[0056] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0057] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0058] Figure 1 This is a flowchart of the data sorting method disclosed in the embodiments of this application;
[0059] Figure 2 This is a schematic diagram of the process for generating intra-segment sorting position description information in the data sorting method disclosed in this application embodiment;
[0060] Figure 3 This is a schematic diagram illustrating the application effect of the data sorting method disclosed in the embodiments of this application;
[0061] Figure 4 This is a schematic diagram of the data sorting device structure disclosed in the embodiments of this application;
[0062] Figure 5 A block diagram schematically illustrates an electronic device for performing the method according to this application; and
[0063] Figure 6 A storage unit for holding or carrying program code implementing the method according to this application is illustrated schematically. Detailed Implementation
[0064] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0065] like Figure 1 As shown in the figure, an embodiment of this application discloses a data sorting method, including steps 110 to 140.
[0066] Step 110: In response to a change in the sorting position of the target data in the data source table, obtain the record identifier and segment sorting number of the target data in the data source table, as well as the value of the preset sorting position influence factor of the target data.
[0067] In database applications, application programs can read the database through database commands, and the database can sort and output all the filtered data according to the application's commands.
[0068] The data source table described in this embodiment is a data list output by the database to the upper-layer application. In the data source table, global data is arranged according to the sorting method specified by the upper-layer application. Each data entry in the data source table includes the following information: record identifier, overall table sort number, segment sort number, and initial intra-segment sort number. For example, the data in the data source table is typically as shown in Table 1 below.
[0069]
[0070] Table 1, Data Source Table
[0071] In Table 1 above, the total table sort number is used to record the actual sequence number of each data item in the data source table. The value of the total table sort number can be calculated based on the segment sort number and the initial intra-segment sort number, or it can be set directly by the database.
[0072] Segment sort numbers are used to distinguish the order in which data is recorded in segments within a data source table. In the data source table, data is recorded in segments at different positions, with records within the same segment being adjacent. In the database, characters that can distinguish the order of data are used to represent different data segments. For example: numbers 1234…, ABCD. Typically, data with smaller segment sort numbers is displayed first, and these data are listed at the top of the data source table. For example, data with segment sort number "A" starts recording from the first row of the data source table, and data with segment sort number "B" starts recording from the Nth row, where N is greater than 1.
[0073] In the table above, the record identifier is a unique identifier for each piece of data in the database, used to uniquely identify a single piece of data.
[0074] In the table above, the initial segment sort number is the record order of each data item within the corresponding segment.
[0075] In some embodiments of this application, applications typically need to adjust the sorting position of some or individual data in the aforementioned data source table. For example, when the data in the aforementioned data source table is a task list of a company or platform, it may be necessary to set task importance levels and place data indicating important task importance at the beginning of the data table. As another example, when the data in the aforementioned data source table is customer service messages, unanswered messages and messages with high importance levels need to be recorded at the beginning of the data table, and then restored to their original positions after being answered. Yet another example is when the data in the aforementioned data source table is tasks or messages; some tasks or messages need to be pinned to the top of the table.
[0076] In the embodiments of this application, the target data is the data whose sorting position needs to be adjusted in the current application operation, that is, the data whose position needs to be sorted by the user operation.
[0077] To address the need to adjust the sorting position of some records in a data source table, as mentioned above, in the embodiments of this application, a sorting position influence factor is pre-set. The application can trigger the data sorting method implemented in this application by setting the value of the sorting position influence factor, sort the data in the data source table, and output a data table with partial sorting adjustment.
[0078] In the embodiments of this application, the type and value of the preset ranking influence factor are set according to specific application requirements. For example, the preset ranking influence factor includes, but is not limited to, one or more of the following: operation sequence number, importance level value, and top-ranking identifier.
[0079] The operation sequence number indicates the order in which data positions need to be adjusted. For example, the operation sequence number of the first data point requiring a sorting adjustment is 1, and the operation sequence number of the second data point requiring a sorting adjustment is 2. Data with a larger operation sequence number has higher priority in selecting its sorting position. For example, the sorting position of the top-ranked data with a larger operation sequence number is lower than the sorting position of the top-ranked data with a smaller operation sequence number. The operation sequence number is numeric, and its value is the total number of operation sequence numbers retrieved for the entire table + 1 when the data is accessed by the application (i.e., when the sorting position needs to be adjusted).
[0080] The importance level value indicates the weighting of the current data in the sorting process. The value of the importance level value is calculated and provided by the application according to the service requirements.
[0081] The pinning flag is used to indicate whether the current data needs to be pinned. The pinning flag is a Boolean type, and its value is calculated and provided by the application according to the service requirements. For example, the pinning flag can be set to "yes" to indicate that it needs to be pinned, that is, the sort number of the data is set to the first position in the data table, and the pinning flag can be set to "no" to indicate that it does not need to be pinned.
[0082] The above only lists a few types of ranking position influencing factors and their value descriptions. In the embodiments of this application, more or other types of ranking position influencing factors can be set according to application requirements, which will not be listed one by one in this embodiment. Those skilled in the art should understand that the above ranking position influencing factors are not a limitation on the embodiments of this application.
[0083] Step 120: Update the pre-created sorting control table according to the values of the record identifier, the segment sorting number, and the preset sorting position influence factor.
[0084] As shown in Table 1, the location and adjustment of a piece of data in the data source table can be determined by controlling [segment sort number] + [initial segment sort number], or by directly setting [total table sort number].
[0085] If data sorting is implemented by modifying the [segment sort number] + [initial segment sort number] or [overall table sort number], when it's necessary to adjust the sorting position of certain data in a specific segment due to triggered conditions, or to automatically restore the sorting position of this local data after the conditions are removed, traditional database sorting methods require traversing all relevant records in the entire table and uniformly modifying the [segment sort number] + [initial segment sort number] or [overall table sort number] values for each record. With massive amounts of data, even a small number of records requiring sorting adjustments can consume significant amounts of memory and computation time.
[0086] In the embodiments of this application, a [sorting control table] is created to associate local records with the global sorting structure, establishing a strong correlation between local records and the global sorting structure. The record identifier ID of the original record is associated with the table entry of the [sorting control table] to obtain sorting control data, calculate sorting parameters, and achieve an efficient sorting scheme.
[0087] In some embodiments of this application, each entry in the sorting control table corresponds to a record identifier, and each entry is used to record information required for sorting the data corresponding to the identifier. For example, the data recorded in each entry of the sorting control table includes: record identifier, segment sort number, intra-segment sorting position control information, and preset sorting position influence factor. The intra-segment sorting position control information may further include: adjusted intra-segment sort number and relative position offset. For example, the sorting control table may be as shown in Table 2.
[0088]
[0089] Table 2, Sorting Control Table
[0090] In Table 2 above, the operation sequence number, importance level value, and top-of-the-line identifier are preset sorting position influencing factors, whose values can be obtained through the application interface; the record identifier is used to uniquely identify a piece of data. Since the entries in the sorting control table record data that needs to be partially sorted, the record identifier in each entry is selected from the data source table; the segment sort number is the segment sort number of the corresponding record identifier in the data source table; the adjusted intra-segment sort number is used to indicate the adjusted sorting position of the data of the corresponding record identifier in the corresponding sorting segment; the relative position offset is used for the position offset of the corresponding data.
[0091] In some embodiments of this application, the value of the relative position offset can be calculated and provided by the application according to service requirements. The relative position offset is an offset that fluctuates up and down from the absolute position. Its function is to control the position of some records, which are generally fixed and only change up and down under certain circumstances. For example, if a data is sorted and is fixed at the 10th segment of a certain sub-segment, when the position of this data needs to be adjusted, the adjustment can be described based on the fixed position of the data and the relative position offset.
[0092] In other embodiments of this application, the relative position offset is calculated based on preset sorting position influence factors such as operation sequence number, importance level value, and top-pinning identifier recorded in this sorting control table. For example, it can be calculated using the formula: Relative position offset = f2(operation sequence number, importance level value, top-pinning identifier). Wherein, f2() is a function relationship constructed according to the sorting requirements of the application.
[0093] In some embodiments of this application, the adjusted intra-segment sort number can be directly specified by the application according to service requirements, or calculated based on preset sorting position influence factors such as operation time sequence number, importance level value, and top-ranking identifier recorded in this sorting control table. For example, it can be calculated using the formula: Adjusted intra-segment sort number = f1(operation time sequence number, importance level value, top-ranking identifier). Wherein, f1() is a function relationship constructed according to the application's sorting requirements.
[0094] In the embodiments of this application, the sorting control table is used to record the mapping relationship between the record identifiers that need to be adjusted in sorting position and the data in the record data source table. The sorting control table does not store all corresponding records from the source table, but only records the top N key data that need to be queried at the current moment, the records with built-in tops in each segment, and records whose relative positions have been moved up or changed by a specified method. Typically, the number of entries in the sorting control table is much smaller than the amount of data in the data source table. Optionally, the number of entries in the sorting control table, i.e., the number of record identifiers, can be set according to service needs.
[0095] The following describes the process of generating the sort control table.
[0096] For example, when an application triggers a change in the sorting position of certain data, such as when operations like "pinning," "change in importance level," or "reply completed" occur in the application, step 110 can be used to obtain the value of the preset sorting position influence factor generated by the application after the user operation occurs, and to obtain the segment sort number and record identifier of the data in the data source table. This information is then transmitted to the calling interface of the data sorting method for recording in the sorting control table. In this embodiment, the update operations for entries in the sorting control table include: adding, modifying, and deleting.
[0097] In some embodiments of this application, updating the pre-created sorting control table based on the values of the record identifier, the segment sorting number, and the preset sorting position influence factor includes the following cases.
[0098] The first scenario: In response to the fact that the record identifier is not recorded in the sorting control table, an entry corresponding to the record identifier is added to the sorting control table according to the value of the preset sorting position influence factor.
[0099] For example, when an application sets unprocessed tasks to be highlighted (e.g., displayed at the top of the task list), after the application queries the task list in the database, the pending task with operation record ID01 is placed at the top. At this time, the application uses this pending task as the target data and sets the value of the preset sorting position influence factor corresponding to the data (e.g., sets the value of the top identifier to "yes" and sets the operation sequence number to 1). Then, the record ID01 of the pending task (i.e., the target data), the segment sorting number of the pending task recorded in the task list (e.g., segment sorting number A), and the value of the preset sorting position influence factor are transmitted to the data sorting method disclosed in the embodiments of this application.
[0100] After obtaining the above information, the data sorting method queries the sorting control table based on record identifier ID01. If record identifier ID01 is not found in the sorting control table, a new entry corresponding to record identifier ID01 is added to the sorting control table, and the following information is recorded in this entry: record identifier (e.g., ID01), segment sort number (e.g., A), operation sequence number (e.g., 1), and top-ranking identifier (e.g., "Yes"). Additionally, for preset sorting position influence factors without specific numerical values, their values can be set to invalid values; for example, the importance level value can be set to 0. Furthermore, if the application specifies the intra-segment sort number and position offset, the corresponding values are recorded in the entry; if the application does not specify the intra-segment sort number and position offset, the sorting control information such as the intra-segment sort number and position offset, which need to be calculated, is initialized.
[0101] Taking the current application operation as an example where the data only contains the data corresponding to record ID01, the updated sorting control table is shown in Table 3.
[0102]
[0103] Table 3, Sorting Control Table
[0104] For example, when an application sets a task issued by a certain department to be highlighted (e.g., displayed at the top of the task list), after the application queries the task list in the database, if the pending task with record ID 01 is already at the top, the application sorts and outputs the tasks issued by that department (such as the pending tasks with records ID 05 and ID 06) in segment B of the data. At this time, the application takes the pending tasks corresponding to records ID 05 and ID 06 as the target data, sets the segment sort number of the data in the data source table to B, sets the value of the preset sorting position influence factor (e.g., sets the top-of-the-line identifier to "No", sets the operation sequence number to 2, and sets the importance level to 1), and then transmits the record IDs ID 05 and ID 06 of the pending task (i.e., the target data), the segment sort number of the pending task in the task list (such as segment sort number B), and the value of the preset sorting position influence factor to the data sorting method disclosed in this application embodiment.
[0105] After obtaining the above information, the data sorting method adds a new entry corresponding to record ID05 in the sorting control table. This entry records the following information: record ID (e.g., ID05), segment sort number (e.g., B), operation sequence number (e.g., 2), top-of-the-table flag (e.g., "No"), and an importance level of 1. It also initializes the segment sort number, position offset, and other necessary sorting control information. Similarly, it adds a new entry corresponding to record ID06 in the sorting control table. This entry records the following information: record ID (e.g., ID06), segment sort number (e.g., B), operation sequence number (e.g., 3), top-of-the-table flag (e.g., "No"), and an importance level of 1. Finally, it initializes the segment sort number, position offset, and other necessary sorting control information.
[0106] The updated sorting control table is shown in Table 4.
[0107]
[0108] Table 4, Sorting Control Table
[0109] The second scenario: In response to the fact that the record identifier has been recorded in the sorting control table, the table entry corresponding to the record identifier recorded in the sorting control table is updated according to the value of the preset sorting position influence factor.
[0110] Based on the sorting control table shown in Table 4, when the application sets a task issued by the aforementioned department (such as the data corresponding to record ID 05) to be highlighted (e.g., to be pinned to the top), the application takes the task to be processed corresponding to record ID 05 as the target data, sets the segment sort number of the data recorded in the data source table to A, and sets the value of the preset sorting position influence factor (e.g., sets the pinning indicator to "yes", sets the operation sequence number to 4, and sets the importance level to 0). Then, record ID 05, the segment sort number of the task to be processed corresponding to record ID 05 recorded in the task list (e.g., segment sort number A), and the value of the preset sorting position influence factor are transmitted to the data sorting method disclosed in this application embodiment.
[0111] After obtaining the above information, the data sorting method searches for the record identifier ID05 of the target data in the sorting control table, locates the second row of the sorting control table, and modifies the information in that row: changing the segment sort number from B to A, changing the operation sequence number to 4, changing the importance level value to 0, and changing the value of the top flag to "Yes". The updated contents of the sorting control table are shown in Table 5.
[0112]
[0113] Table 5, Sorting Control Table
[0114] The third scenario: Delete the entry corresponding to the record identifier from the sorting control table.
[0115] Based on the sorting control table shown in Table 4, when the application cancels the pinning of a task (such as the data corresponding to record ID 01), the application takes the task to be processed corresponding to record ID 01 as the target data, sets the segment sort number of the data in the data source table to A, and sets the value of the preset sorting position influence factor (for example, setting the pinning identifier to "No", setting the operation sequence number to 5, and setting the importance level to 0). Then, record ID 01, the segment sort number of the task to be processed corresponding to record ID 01 in the task list (such as segment sort number A), and the value of the preset sorting position influence factor are transmitted to the data sorting method disclosed in this application embodiment.
[0116] After obtaining the above information, the data sorting method searches for the record identifier ID01 of the target data in the sorting control table, locating the first row of the sorting control table. Then, based on the value of the preset sorting position influence factor, it determines whether the data needs to be removed from the top position, and deletes the row corresponding to record identifier ID01 from the sorting control table. The updated contents of the sorting control table are shown in Table 6.
[0117]
[0118] Table 6, Sorting Control Table
[0119] The sorting control information related to each application operation that adjusts the sorting position of data will be recorded in the sorting control table until the data is restored to its original position. For example, if the data is removed from the top, its importance level is reduced, or it is specified to be sorted to the end of the table, the corresponding table entry will be deleted from the sorting control table.
[0120] Step 130: Generate intra-segment sorting position description information based on the updated sorting control table.
[0121] When it is necessary to adjust the sorting position of data in a data source table and output it in a sorted manner, the information of each record in the sorting control table can be used to generate intra-segment sorting position description information based on record identifiers and preset characters in a preset format. This intra-segment sorting position description information describes the adjusted sorting order and interval of the data corresponding to each record identifier.
[0122] In some embodiments of this application, such as Figure 2 As shown, according to the updated sorting control table, the intra-segment sorting position description information is generated, including: sub-step 1301, sub-step 1302, sub-step 1303 and sub-step 1304.
[0123] Sub-step 1301: Based on the value of the preset sorting position influence factor corresponding to each record identifier in the updated sorting control table, obtain the intra-segment sorting position control information corresponding to each record identifier.
[0124] Next, we can iterate through the entries corresponding to each record identifier in the sorting control table, compare the operation sequence number, importance level value, and top identifier corresponding to each record identifier, and assign different weights to the influence factors of each preset sorting position according to the different service requirements of each application, and calculate the intra-segment sorting number and relative position offset corresponding to each record identifier.
[0125] Taking data as an example, for company-level tasks, due to their importance, they need to be prioritized. The "Importance Level Value" can be set to adjust the sorting position. Similarly, for tasks nearing their expiration date, attention is needed. This can be achieved by setting a "Pin to Top" flag, adjusting the relative position offset, or directly setting the intra-segment sorting number. Furthermore, changes in the execution status of certain tasks (such as being clicked, receiving a response, or being manipulated) also need to be monitored, as these actions affect the operation sequence number. Applications can set the type and value of sorting position influencing factors according to specific needs.
[0126] As mentioned earlier, the intra-segment sorting position control information includes: intra-segment sorting number, and / or, relative position offset. Before sorting the sorting control table, it is first necessary to calculate the information used for intra-segment sorting, i.e., the intra-segment sorting position control information. The method for calculating the intra-segment sorting number and relative position offset based on the preset sorting position influence factor is as described above and will not be repeated here.
[0127] Optionally, the application can also directly set the segment sort number or relative position offset of the data corresponding to one or more records. For example, a certain data can be designated as the top record, positioned at the first position within segment A. Another example is specifying the fixed position of a certain data within a segment.
[0128] Sub-step 1302: Based on the segment sorting number and the intra-segment sorting position control information, sort each item in the sorting control table from beginning to end, so that the item corresponding to the record identifier with the output position first is arranged at the beginning of the sorting control table.
[0129] When sorting each item in the sorting control table from beginning to end according to the segment sorting number and the intra-segment sorting position control information, firstly, the items in the sorting control table are sorted from the beginning to the end according to the output position corresponding to the segment sorting number. Then, the items with the same segment sorting number are sorted from the beginning to the end according to the intra-segment sorting number, or according to the intra-segment sorting position determined by the intra-segment sorting number and the relative position offset.
[0130] Specifically, the entry corresponding to the record identifier with segment sequence number A can be placed at the beginning of the sort control table. Then, the entries corresponding to the record identifier with segment sequence number B, segment sequence number C, and so on, are arranged sequentially towards the end of the table. Record identifiers with the same segment sequence number will be recorded in an adjacent entry.
[0131] Furthermore, for record identifiers with the same segment sort number, their entries are arranged sequentially from the beginning to the end of the table according to the segment sort number in ascending order. For example, for a record identifier with segment sort number A, the entry with the smallest segment sort number is placed at the beginning of the sort control table, and then each entry with segment sort number A is arranged sequentially towards the end of the table until all entries corresponding to the record identifier with segment sort number A are arranged.
[0132] Sub-step 1303: Traverse each entry of the sorting control table from the beginning to the end of the table to obtain the sorting order of each record identifier and the sorting position interval between two adjacent record identifiers with the same segment sorting number.
[0133] After the aforementioned sorting steps, the resulting sorting control table has entries at the beginning corresponding to data to be output first, and entries at the end corresponding to data to be output last. In this step, by traversing each entry of the sorted sorting control table from the beginning to the end, the record identifier in each entry is obtained sequentially; this record identifier is the identifier of the data to be output in front-to-back order.
[0134] Furthermore, for entries with the same segment sort number, subtracting the segment sort number of the previous entry from the segment sort number of the next entry yields the number of data items that need to be sorted and adjusted. Alternatively, the number of data items that need to be sorted and adjusted, i.e., the sorting position interval, can be obtained by using the relative position offset in the next entry.
[0135] For example, when the first entry in the sorted sorting control table records record ID01, segment sort number A, and intra-segment sort number 1, and the second entry records record ID05, segment sort number A, and intra-segment sort number 5, after traversing each entry of the sorting control table from the beginning to the end, it can be found that the sorting positions of record ID01 and ID05 are record ID01 first and ID05 second, and the sorting position interval between record ID01 and ID05 is 5-1-1=3.
[0136] Sub-step 1304: Based on the sorting order of the record identifiers and the sorting position interval between two adjacent record identifiers, generate a description text in a preset format as the intra-segment sorting position description information.
[0137] After obtaining the sorting order of each record identifier in the sorting control table, and the sorting position interval between two adjacent record identifiers corresponding to the same segment sorting number, a description text is generated according to a preset format based on the obtained sorting order information and sorting position interval of each record identifier, combined with the total number of records in the data source table, the current operation sequence number of the entire table, and the total number of data corresponding to each segment sorting number, as the intra-segment sorting position description information.
[0138] In some embodiments of this application, generating a description text in a preset format based on the sorting order of the record identifiers and the sorting position interval between two adjacent record identifiers includes: separating the record identifiers arranged in the sorting order with a preset separator, and inserting a preset number of placeholders matching the sorting position interval between two adjacent record identifiers to generate a description text in a preset format.
[0139] In some embodiments of this application, the segment sorting position description information is a string composed of a record identifier ID, a separator, and a placeholder. The order of the record identifiers within the string determines the order of the data corresponding to those record identifiers within each segment during sorting output. The specific position of the data can be adjusted by inserting the number of placeholders. The separator and placeholders can use predefined symbols; for example, the separator can be the symbol " / ", and the placeholder can be the symbol "#".
[0140] Taking the sorting control table shown in Table 5 as an example, starting from the top of the table, the obtained record identifiers are ID01, ID05, and ID06 in sequence. If the sorting position interval between record identifiers ID01 and ID05 is 3, and the sorting position interval between record identifiers ID05 and ID06 is 0, then the generated description text in the preset format can be represented as: " / ID01 / ### / ID05 / ID06".
[0141] The segment sorting position description information will be used by the character search instruction to obtain the sorting parameter value.
[0142] Step 140: Sort and output the data in the data source table according to the sorting position description information within the segment.
[0143] During the database sorting stage, the application can use the segment sorting position description information as sorting parameters, and combine it with the data source table to sort and output the data in the data source table.
[0144] In some embodiments of this application, sorting and outputting data in the data source table according to the intra-segment sorting position description information includes: for data to be sorted in the data source table, obtaining the segment sorting number of the data through the data source table, and obtaining the intra-segment sorting number of the data through the intra-segment sorting position description information; sorting and outputting the data according to the obtained segment sorting number and the intra-segment sorting number.
[0145] When retrieving data from a data source table, the order of data segments can be directly determined by the segment sort number field in the data source table. The intra-segment sort number within each segment can be determined by calculating the position number of the corresponding data ID in the intra-segment sort position description information.
[0146] Taking SQL database queries as an example, the SELECT statement can be used to select and sort data from a data source table. Its syntax can be expressed as follows:
[0147] Select [field1], [field2], ... from [data source table] where [filter criteria] Order By [segment sort number], [sort field2], [sort field3]...
[0148] Among them, sorting field 2 can be the intra-segment sorting number of the corresponding segment sorting number.
[0149] Optionally, the intra-segment sort number can be determined using a character lookup function. For example, the InStr() function can be used to obtain the intra-segment sort number of a specified record identifier using the intra-segment sort position description information. Specifically, the statement "[sort field 2] = "InStr('[intra-segment sort position description information]', [record identifier ID])" can be used to obtain the intra-segment sort position of the record identifier ID recorded in the intra-segment sort position description information.
[0150] The InStr() function returns the position of the first occurrence of one string within another string. If the segment sorting position description is " / ID01 / ### / ID05 / ID06", executing the above statement, i.e., executing the statement InStr(' / ID01 / ### / ID05 / ID06', 'ID06'), will return the segment sorting position of record ID06, resulting in a value of 5 for sorting field 2.
[0151] In some embodiments of this application, obtaining the intra-segment sorting number of the data through the intra-segment sorting position description information includes: querying whether the intra-segment sorting position description information includes a record identifier of the data; in response to the intra-segment sorting position description information including the record identifier, obtaining the position number of the record identifier in the intra-segment sorting position description information through a preset character query instruction, and obtaining the intra-segment sorting number of the data according to the position number; in response to the intra-segment sorting position description information not including the record identifier, setting the intra-segment sorting number of the data to a specified sorting number.
[0152] The specified sort number indicates the sorting position of the data within the initial segment of the data source table.
[0153] Considering the case where the record identifier does not exist in the intra-segment sorting position description information (e.g., the record identifier of data whose sorting position has not been locally adjusted when the application queries), in some embodiments of this application, the system first queries whether the target record identifier exists in the intra-segment sorting position description information. If it exists, the system further queries the intra-segment sorting number of the target record identifier using the aforementioned character query instruction. If it does not exist, the system returns an instruction value that indicates the intra-segment sorting position corresponding to the record identifier as the initial intra-segment sorting position of the data in the data source table.
[0154] For example, the statement above for calculating sorting field 2 can be optimized as follows:
[0155] [Sort field 2] = "IF('[Segment sort position description information]' like '% / '+[Record ID]+' / %'=true, InStr('[Segment sort position description information]',[Record ID]), M)", where M is a positive integer determined based on the total amount of data in the data source table, used to set the segment sort number of the data corresponding to the record ID that is not in the segment sort position description information to the end of the table.
[0156] Those skilled in the art should understand that the above syntax for "like", "InStr" and string concatenation is based on the SQL database language. In different versions of SQL or different database languages, the statement for querying the first occurrence of a string in another string may be different.
[0157] In other embodiments of this application, other formats can be used to generate the intra-segment sorting position description information. For example, the intra-segment sorting number of each record identifier can be described using the format of record identifier + intra-segment sorting number + separator. For example, the intra-segment sorting position description information generated by the sorting control table in Table 5 can be represented as " / ID01 / 1 / ID05 / 5 / ID06 / 6". Accordingly, during sorting output, the intra-segment sorting position description information can be parsed according to its format to obtain the intra-segment sorting number of each target record identifier; and the data in the data source table can be sorted and output according to the segment sorting number corresponding to each target record identifier in the data source table and the intra-segment sorting number of each target record identifier.
[0158] This achieves the goal of adjusting the sorting position of the data corresponding to the record identifier in the sorting control table in the data source table, without needing to traverse and sort all the data in the data source table.
[0159] Taking the data sorting method disclosed in this application as an example, applied to the list management module of an enterprise's safety production management system, the list management module needs to adjust the record sorting in real time for each department's task list based on real-time data such as task start time, completion deadline, pinning status, and whether the task is unread / read / incomplete / complete / has a reply. After using the data sorting method disclosed in this application, it ensures that even with large data volumes, the required dynamic task lists are provided to each department in real time with relatively small system memory and time resource consumption. Figure 3 As shown, for example, tasks related to science and technology innovation management should be pinned to the top for focused attention.
[0160] This application also discloses a data sorting method that, in response to a change in the sorting position of target data in a data source table, obtains the record identifier and segment sorting number of the target data in the data source table, as well as the value of a preset sorting position influence factor for the target data; updates a pre-created sorting control table based on the record identifier, the segment sorting number, and the value of the preset sorting position influence factor; generates intra-segment sorting position description information based on the updated sorting control table; and sorts and outputs the data in the data source table based on the intra-segment sorting position description information. This method eliminates the need to traverse the data source table; it only requires calculations on the sorting control table to adjust the sorting position of local data, reducing computational load and improving sorting efficiency.
[0161] The data sorting method disclosed in this application also creates a sorting control table and establishes related parameters between the sorting control table and the data source table (such as the sorting position description information within a segment, the total number of records in the data source table, the total number of data in each segment of the data source table, and the current total operation sequence number). These parameters are used to calculate and store the correlation information of the mutual influence of local records on the overall sorting structure of the data source table, as well as the key record position information data involved in the output sorting. This changes the original need to traverse and calculate the sorting structure of all records in the table to operations only on the sorting control table and related data source table parameters. Since the sorting control table only records the key records that are of concern for the sorting output, as well as records whose positions have changed, its number is far less than the total number of records in the data source table. Therefore, it effectively reduces the consumption of memory and time resources. For applications where the data source table contains hundreds of thousands of data points, it has high value in terms of the quality of sorting output services.
[0162] Accordingly, embodiments of this application also disclose a data sorting device, such as... Figure 4 As shown, the device includes:
[0163] The sorting information acquisition module 410 is used to acquire the record identifier and segment sort number of the target data in the data source table, as well as the value of the preset sorting position influence factor of the target data, in response to a change in the sorting position of the target data in the data source table.
[0164] The sorting control table update module 420 is used to update the pre-created sorting control table according to the values of the record identifier, the segment sort number and the preset sorting position influence factor.
[0165] The segment sorting position description information generation module 430 is used to generate segment sorting position description information based on the updated sorting control table.
[0166] The sorting output module 440 is used to sort and output the data in the data source table according to the sorting position description information within the segment.
[0167] Optionally, the sorting control table update module 420 is further configured to perform any of the following operations:
[0168] Delete the entry corresponding to the record identifier from the sorting control table;
[0169] In response to the fact that the record identifier is not recorded in the sorting control table, an entry corresponding to the record identifier is added to the sorting control table according to the value of the preset sorting position influence factor;
[0170] In response to the fact that the record identifier has been recorded in the sorting control table, the table entry corresponding to the record identifier recorded in the sorting control table is updated according to the value of the preset sorting position influence factor;
[0171] The table entries include: the record identifier, the segment sort number, and the value of the preset sort position influence factor.
[0172] Optionally, generating intra-segment sorting position description information based on the updated sorting control table includes:
[0173] Based on the value of the preset sorting position influence factor corresponding to each record identifier in the updated sorting control table, obtain the intra-segment sorting position control information corresponding to each record identifier;
[0174] Based on the segment sorting number and the sorting position control information within the segment, each item in the sorting control table is sorted from beginning to end, so that the item corresponding to the record identifier that is first in the output position is arranged at the beginning of the sorting control table.
[0175] Traverse each entry of the sorting control table from the beginning to the end of the table to obtain the sorting order of each record identifier, and the sorting position interval between two adjacent record identifiers with the same segment sorting number.
[0176] Based on the sorting order of the record identifiers and the sorting position interval between two adjacent record identifiers, a pre-formatted description text is generated as the intra-segment sorting position description information.
[0177] Optionally, generating a description text in a preset format based on the sorting order of the record identifiers and the sorting position interval between two adjacent record identifiers includes:
[0178] The record identifiers arranged in the sorting order are separated by a preset separator, and a preset number of placeholders matching the sorting position interval are inserted between the corresponding two record identifiers according to the sorting position interval between two adjacent record identifiers to generate a description text in a preset format.
[0179] In some embodiments of this application, the sorting output module 440 is further configured to:
[0180] For the data to be sorted in the data source table, the segment sort number of the data is obtained through the data source table, and the intra-segment sort number of the data is obtained through the intra-segment sort position description information.
[0181] The data is sorted and output based on the obtained segment sort number and the intra-segment sort number.
[0182] Optionally, obtaining the intra-segment sort number of the data through the intra-segment sort position description information includes:
[0183] Check whether the record identifier of the data is included in the sorting position description information within the segment;
[0184] In response to the inclusion of the record identifier in the intra-segment sorting position description information, the position number of the record identifier in the intra-segment sorting position description information is obtained through a preset character query instruction, and the intra-segment sorting number of the data is obtained based on the position number;
[0185] In response to the fact that the record identifier is not included in the intra-segment sorting position description information, the intra-segment sorting number of the data is set to the specified sorting number.
[0186] The data sorting apparatus disclosed in this application is used to implement the data sorting method described in this application. The specific implementation methods of each module of the apparatus will not be repeated here, but can be found in the specific implementation methods of the corresponding steps in the method embodiments.
[0187] This application discloses a data sorting device that, in response to a change in the sorting position of target data in a data source table, obtains the record identifier and segment sorting number of the target data in the data source table, as well as the value of a preset sorting position influence factor for the target data; updates a pre-created sorting control table based on the record identifier, segment sorting number, and the value of the preset sorting position influence factor; generates intra-segment sorting position description information based on the updated sorting control table; and sorts and outputs the data in the data source table based on the intra-segment sorting position description information. This device achieves local data sorting position adjustment without traversing the data source table, requiring only calculations on the sorting control table, thus reducing computational load and improving sorting efficiency.
[0188] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus embodiments, since they are substantially similar to the method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0189] The above provides a detailed description of a data sorting method and apparatus provided by this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method of this application and its core idea. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the idea of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
[0190] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0191] The various component embodiments of this application can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the electronic device according to the embodiments of this application. This application can also be implemented as a device or apparatus program (e.g., a computer program and computer program product) for performing part or all of the methods described herein. Such an implementation of this application can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0192] For example, Figure 5An electronic device is shown that can implement the methods according to this application. The electronic device may be a PC, mobile terminal, personal digital assistant, tablet computer, etc. The electronic device conventionally includes a processor 510 and a memory 520, and program code 530 stored in the memory 520 and executable on the processor 510, which, when executing the program code 530, implements the methods described in the above embodiments. The memory 520 may be a computer program product or a computer-readable medium. The memory 520 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. The memory 520 has a storage space 5201 for the program code 530 of a computer program for performing any of the method steps described above. For example, the storage space 5201 for the program code 530 may include various computer programs for implementing the various steps in the methods described above. The program code 530 is computer-readable code. These computer programs can be read from or written to one or more computer program products. These computer program products include program code carriers such as hard disks, CDs, memory cards, or floppy disks. The computer program includes computer-readable code that, when executed on an electronic device, causes the electronic device to perform the method according to the above embodiments.
[0193] This application also discloses a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the data sorting method as described in this application.
[0194] Such a computer program product can be a computer-readable storage medium, which can have the same characteristics as... Figure 5 The memory 520 in the illustrated electronic device is similarly arranged with storage segments, storage spaces, etc. Program code can be stored, for example, in a compressed form on the computer-readable storage medium. The computer-readable storage medium is typically as shown in the reference. Figure 6 The portable or fixed storage unit is described above. Typically, the storage unit includes computer-readable code 530', which is code read by a processor and, when executed by the processor, implements the various steps of the method described above.
[0195] The terms "an embodiment," "embodiment," or "one or more embodiments" as used herein mean that a particular feature, structure, or characteristic described in connection with an embodiment is included in at least one embodiment of this application. Furthermore, please note that the examples of the phrase "in one embodiment" do not necessarily all refer to the same embodiment.
[0196] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of this application may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0197] In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. This application can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
[0198] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A data sorting method, characterized in that, The method includes: In response to a change in the sorting position of the target data in the data source table, the record identifier and segment sorting number of the target data in the data source table are obtained, as well as the value of the preset sorting position influence factor of the target data. Update the pre-created sorting control table based on the values of the record identifier, the segment sort number, and the preset sorting position influence factor; Based on the updated sorting control table, generate intra-segment sorting position description information; Based on the sorting position description information within the segment, sort and output the data in the data source table; The step of updating the pre-created sorting control table based on the values of the record identifier, the segment sorting number, and the preset sorting position influence factor includes any one of the following operations: Delete the entry corresponding to the record identifier from the sorting control table; In response to the fact that the record identifier is not recorded in the sorting control table, an entry corresponding to the record identifier is added to the sorting control table according to the value of the preset sorting position influence factor; In response to the fact that the record identifier has been recorded in the sorting control table, the table entry corresponding to the record identifier recorded in the sorting control table is updated according to the value of the preset sorting position influence factor; The table entries include: the record identifier, the segment sort number, and the value of the preset sort position influence factor; The step of generating intra-segment sorting position description information based on the updated sorting control table includes: Based on the value of the preset sorting position influence factor corresponding to each record identifier in the updated sorting control table, obtain the intra-segment sorting position control information corresponding to each record identifier; Based on the segment sorting number and the sorting position control information within the segment, each item in the sorting control table is sorted from beginning to end, so that the item corresponding to the record identifier that is first in the output position is arranged at the beginning of the sorting control table. Traverse each entry of the sorting control table from the beginning to the end of the table to obtain the sorting order of each record identifier, and the sorting position interval between two adjacent record identifiers with the same segment sorting number. Based on the sorting order of the record identifiers and the sorting position interval between two adjacent record identifiers, a description text in a preset format is generated as the sorting position description information within the segment. The step of generating a pre-formatted descriptive text based on the sorting order of the record identifiers and the sorting position interval between two adjacent record identifiers includes: The record identifiers arranged in the sorting order are separated by a preset separator, and a preset number of placeholders matching the sorting position interval are inserted between the corresponding two record identifiers according to the sorting position interval between two adjacent record identifiers to generate a description text in a preset format.
2. The method according to claim 1, characterized in that, The step of sorting and outputting the data in the data source table according to the sorting position description information within the segment includes: For the data to be sorted in the data source table, the segment sort number of the data is obtained through the data source table, and the intra-segment sort number of the data is obtained through the intra-segment sort position description information. The data is sorted and output based on the obtained segment sort number and the intra-segment sort number.
3. The method according to claim 2, characterized in that, The step of obtaining the intra-segment sort number of the data through the intra-segment sort position description information includes: Check whether the record identifier of the data is included in the sorting position description information within the segment; In response to the inclusion of the record identifier in the intra-segment sorting position description information, the position number of the record identifier in the intra-segment sorting position description information is obtained through a preset character query instruction, and the intra-segment sorting number of the data is obtained based on the position number; In response to the fact that the record identifier is not included in the intra-segment sorting position description information, the intra-segment sorting number of the data is set to the specified sorting number.
4. A data sorting device, characterized in that, The device includes: The sorting information acquisition module is used to acquire the record identifier and segment sort number of the target data in the data source table, as well as the value of the preset sorting position influence factor of the target data, in response to a change in the sorting position of the target data in the data source table. The sorting control table update module is used to update the pre-created sorting control table according to the values of the record identifier, the segment sort number and the preset sorting position influence factor. The segment sorting position description information generation module is used to generate segment sorting position description information based on the updated sorting control table. The sorting output module is used to sort and output the data in the data source table according to the sorting position description information within the segment; The sorting control table update module is further configured to perform any of the following operations: Delete the entry corresponding to the record identifier from the sorting control table; In response to the fact that the record identifier is not recorded in the sorting control table, an entry corresponding to the record identifier is added to the sorting control table according to the value of the preset sorting position influence factor; In response to the fact that the record identifier has been recorded in the sorting control table, the table entry corresponding to the record identifier recorded in the sorting control table is updated according to the value of the preset sorting position influence factor; The table entries include: the record identifier, the segment sort number, and the value of the preset sort position influence factor; The segment sorting position description information generation module is also used to obtain the segment sorting position control information corresponding to each record identifier based on the value of the preset sorting position influence factor corresponding to each record identifier in the updated sorting control table. Based on the segment sorting number and the sorting position control information within the segment, each item in the sorting control table is sorted from beginning to end, so that the item corresponding to the record identifier that is first in the output position is arranged at the beginning of the sorting control table. Traverse each entry of the sorting control table from the beginning to the end of the table to obtain the sorting order of each record identifier, and the sorting position interval between two adjacent record identifiers with the same segment sorting number. Based on the sorting order of the record identifiers and the sorting position interval between two adjacent record identifiers, a description text in a preset format is generated as the sorting position description information within the segment. The step of generating a pre-formatted description text based on the sorting order of the record identifiers and the sorting position interval between two adjacent record identifiers includes: The record identifiers arranged in the sorting order are separated by a preset separator, and a preset number of placeholders matching the sorting position interval are inserted between the corresponding two record identifiers according to the sorting position interval between two adjacent record identifiers to generate a description text in a preset format.
5. The apparatus according to claim 4, characterized in that, The sorting output module is further used for: For the data to be sorted in the data source table, the segment sort number of the data is obtained through the data source table, and the intra-segment sort number of the data is obtained through the intra-segment sort position description information. The data is sorted and output based on the obtained segment sort number and the intra-segment sort number.
6. An electronic device, comprising a memory, a processor, and program code stored in the memory and executable on the processor, characterized in that, When the processor executes the program code, it implements the data sorting method according to any one of claims 1 to 3.
7. A computer-readable storage medium having program code stored thereon, characterized in that, When the program code is executed by the processor, it implements the steps of the data sorting method according to any one of claims 1 to 3.