List reordering method and device, computer equipment and readable storage medium

By adding sorting status values ​​to list elements and correcting them, the optimal sorting value update solution is calculated, and the problem of frequent submission of back-end requests and updating databases in the prior art is solved, and the effect of reducing network pressure and database resource consumption is achieved.

CN119576175APending Publication Date: 2025-03-07CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411700453.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

When adjusting the order of list elements, the prior art requires frequent submission of back-end requests and updating databases, resulting in high network pressure and wasted database resources.

Method used

By adding sorted state values ​​to list elements and correcting them based on these state values, the optimal sorted value update scheme is calculated, and only the changed sorted value is updated, reducing database write operations.

Benefits of technology

It reduces the number of submissions and database updates of the backend requests, reduces network pressure and database resource consumption, and improves the efficiency of sorting value adjustment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576175A_ABST
    Figure CN119576175A_ABST
Patent Text Reader

Abstract

The invention relates to a list reordering method and device, computer equipment and a computer readable storage medium. Comprising the steps that a reordered element list is received, the reordered element list comprises a plurality of elements arranged in sequence, and each element corresponds to an element identifier and an original ordering value; adding a sorting state value for each element in the element list, wherein the initial value of the sorting state value is consistent with the original sorting value corresponding to the element; based on the element list, correcting the sorting state value of at least one element, and determining a target sorting state value of each element in the element list; target elements with the original sorting values inconsistent with the target sorting state values are screened out; and according to the element identifier of the target element, taking the target sorting state value of the target element as an updated sorting value, and writing the updated sorting value into a database. By adopting the method, the submission times of the back-end request can be reduced, and the network pressure is relieved; the number of times of updating data in the database can be reduced, and database resources are saved; and the sorting value adjustment efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet technology, and in particular to a list reordering method, apparatus, computer equipment, and computer-readable storage medium. Background Art

[0002] Currently, when designing a sortable list, an integer sorting attribute is usually added to all elements in the list. The smaller the value, the higher the ranking of the element, and vice versa. There are two traditional interactive methods to adjust the order of list elements:

[0003] 1. Enter the sorting mode. After adjusting the order of the list elements, the front end submits the sorted list of elements to the back end at one time. The back end sets the sorting values ​​for the elements in the list in sequence. For example, the sorting values ​​set in sequence are 1, 2, 3, 4, 5, ..., and the new sorting values ​​are updated to the database.

[0004] 2. If the sorting mode is not set, the user can only adjust the sorting position of one element at a time, and the front end needs to submit data once for each adjustment. For example, the initial sorting values ​​of all elements are 1000, 2000, 3000, 4000, 5000, ... When adjusting the position, the back end obtains the sorting values ​​of the previous and next elements of the current element after sorting, and takes an intermediate number between the two sorting values ​​of the previous and next elements as the new sorting value of the current element. If the sorting values ​​of the previous and next elements are the same, or the two sorting values ​​differ by only 1, and an integer cannot be taken as the intermediate number, the sorting values ​​of all elements are reinitialized to 1000, 2000, 3000, 4000, 5000, ...

[0005] The advantage of the first traditional interaction method is that you only need to submit a request once to adjust the positions of multiple elements. The disadvantage is that each adjustment requires updating the sorting values ​​of most elements in the list, which puts a lot of pressure on the database. In extreme cases, if you only adjust the first element to the last position in the list, you also need to update the sorting values ​​of all elements, which wastes a lot of database resources.

[0006] The advantage of the second traditional interaction method is that each request basically only needs to update the sorting value of the changed element, and the sorting values ​​of other elements do not need to be changed. The disadvantage is that a request must be initiated every time the position of an element is adjusted. If there are many elements that need to be adjusted, multiple backend requests need to be submitted, which increases network pressure and has low sorting adjustment efficiency. Summary of the invention

[0007] Based on this, it is necessary to provide a list reordering method, device, computer equipment and computer-readable storage medium to address the above technical problems, which can reduce the number of submissions of backend requests and the number of updates to data in the database.

[0008] In a first aspect, the present application provides a list reordering method, comprising:

[0009] receiving a reordered element list; the element list includes a plurality of elements arranged in order, each element corresponding to an element identifier and an original sort value;

[0010] Add a sorting state value to each element in the element list; the initial value of the sorting state value of each element is consistent with the original sorting value corresponding to the element;

[0011] Based on the element list, modifying the sorting state value of at least one element to determine a target sorting state value for each element in the element list;

[0012] Filter out target elements whose original sorting values ​​are inconsistent with the target sorting status values;

[0013] According to the element identifier of the target element, the target sorting state value of the target element is written into the database as an updated sorting value.

[0014] In one embodiment, based on the element list, modifying the sorting state value of at least one element to determine the target sorting state value of each element in the element list includes:

[0015] Calculate the corrected score of each element based on the element list and the current sorting status value of each element;

[0016] Determine whether the modified score of each element is equal to the preset value;

[0017] If the revised score of each element is equal to the preset value, the current ranking state value of each element is determined as the target ranking state value of each element in the element list;

[0018] If the correction score of at least one element is not equal to the preset value, determining the element to be corrected from the multiple elements according to the correction score;

[0019] Correct the sorting status value of the element to be corrected;

[0020] Returns the step that computes the modified score for each element based on the list of elements and its current sort status value.

[0021] In one embodiment, the modified score includes a left modified score and a right modified score; and the modified score of each element is calculated according to the element list and the current sorting state value of each element, including:

[0022] For each element in the element list, start with the current element and traverse to the first element in the element list, record the number of first elements whose sorting state value is not less than the current element, and set the number of first elements as the left corrected score of the current element;

[0023] Starting from the current element, traverse to the last element in the element list, record the number of second elements whose sorting state value is not greater than the current element, and set the number of second elements as the right-corrected score of the current element.

[0024] In one embodiment, determining an element to be corrected from a plurality of elements according to the correction score includes:

[0025] Calculate the sum of the left-corrected score and the right-corrected score of each element to get the total score of each element;

[0026] The element with the highest total score among multiple elements is determined as the element to be corrected.

[0027] In one embodiment, the method further comprises:

[0028] If there are multiple elements with the highest total score, the non-latest revised elements among the elements with the highest total score are determined as the elements to be revised; the non-latest revised elements refer to elements that have been revised before but not the most recent revision;

[0029] If there are multiple non-latest revised elements among the elements with the highest total score, the element closest to the first element or the last element among the multiple non-latest revised elements is determined as the element to be revised;

[0030] If multiple elements with the highest total scores have not been corrected, the element closest to the first element or the last element among the elements with the highest total scores is determined as the element to be corrected.

[0031] In one embodiment, modifying the sorting state value of the element to be modified includes:

[0032] If the element to be corrected is the first element in the element list, then determine the current minimum sorting state value among the multiple elements, and use the product of the minimum sorting state value and the preset coefficient as the corrected sorting state value of the element to be corrected;

[0033] If the element to be corrected is the last element in the element list, then determine the current maximum sorting state value among the multiple elements, and use the sum of the maximum sorting state value and the preset additional value as the corrected sorting state value of the element to be corrected;

[0034] If the element to be corrected is the middle element of the element list, the average value of the current sorting state values ​​of the adjacent elements of the element to be corrected is used as the corrected sorting state value of the element to be corrected.

[0035] In one of the embodiments, before receiving the reordered list of elements, the method further includes:

[0036] Receive element list request;

[0037] According to the element list request, query the corresponding data in the database;

[0038] An initial element list is generated according to the queried data, and feedback is given to the initial element list; the initial element list includes a plurality of elements arranged in the original order, and each element corresponds to an element identifier and an original sort value.

[0039] In a second aspect, the present application further provides a list reordering device, comprising:

[0040] A receiving module, used for receiving a reordered element list; the element list includes a plurality of elements arranged in sequence, each element corresponding to an element identifier and an original sort value;

[0041] The attribute adding module is used to add a sorting status value to each element in the element list; the initial value of the sorting status value of each element is consistent with the original sorting value corresponding to the element;

[0042] A correction module, used to correct the sorting state value of at least one element based on the element list, and determine the target sorting state value of each element in the element list;

[0043] The sorting module is used to filter out target elements whose original sorting values ​​are inconsistent with the target sorting state values; and write the target sorting state values ​​of the target elements as updated sorting values ​​into the database according to the element identifiers of the target elements.

[0044] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method described in the first aspect above are implemented.

[0045] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method described in the first aspect above are implemented.

[0046] The above-mentioned list reordering method, device, computer equipment and computer-readable storage medium receive a reordered element list; the element list includes multiple elements arranged in order, each element corresponds to an element identifier and an original sort value; a sort state value is added to each element in the element list; the initial value of the sort state value of each element is consistent with the original sort value corresponding to the element; based on the element list, the sort state value of at least one element is corrected to determine the target sort state value of each element in the element list; the target element whose original sort value is inconsistent with the target sort state value is screened out; according to the element identifier of the target element, the target sort state value of the target element is written into the database as the updated sort value. Among them, even if the front end modifies the sort value of multiple elements, it only needs to submit a request once, which can be reflected in the same reordered element list. By adding the sort state value and correcting it, the optimal sort value update scheme can be calculated, and only the changed sort value is written into the database, reducing the write operation to the database. Through the above method, the number of submissions of back-end requests can be reduced, reducing network pressure; the number of updates to data in the database can also be reduced, saving database resources; and thus improving the efficiency of sort value adjustment. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0048] Figure 1 A diagram of an application environment of a list reordering method in an embodiment;

[0049] Figure 2 is a flowchart of a list reordering method in one embodiment;

[0050] Figure 3 A schematic diagram of a flow chart of a sorting state value correction step in one embodiment;

[0051] Figure 4 is a flow chart of a list reordering method in another embodiment;

[0052] Figure 5 is a structural block diagram of a list reordering device in one embodiment;

[0053] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0055] The list reordering method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the client 102 communicates with the server 104 through the network. A database is set on the data storage system, and data that the server 104 needs to process can also be stored. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The client 102 can be an application or browser running on the terminal, and the user interface (i.e., the front end) of the client 102 is responsible for receiving user input, sending requests to the server, and displaying data fed back by the server. The server 104 receives the request of the client 102 as the back end, and the request includes a reordered list of elements; the server 104 performs the steps of the list reordering method provided in any embodiment of the present application based on the reordered list of elements.

[0056] The terminal running the client 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices. The portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The head-mounted devices may be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. The server 104 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.

[0057] In an exemplary embodiment, Figure 2 As shown, a list reordering method is provided, which is applied to Figure 1 The server 104 in FIG. 1 is used as an example to illustrate, including:

[0058] Step 202, receiving a reordered element list; the element list includes a plurality of elements arranged in sequence, each element corresponding to an element identifier and an original sort value.

[0059] Among them, the user adjusts the order of each element in the list based on the front end, and submits the reordered element list to the backend server at one time. Each element in the element list includes the following key attributes: element identifier (i.e. element ID), which refers to the unique identifier of the corresponding element in the database; original sort value (srcIndex), integer type, the smaller the value, the higher the original sort in the database, and vice versa. The original sort value refers to the sort value of each element in the database. The order of each element in the element list is used to indicate the user's reordering results for each element.

[0060] Step 204, adding a sorting state value to each element in the element list; the initial value of the sorting state value of each element is consistent with the original sorting value corresponding to the element.

[0061] A tmpIndex attribute (ie, a sorting status value) is added to each element in the element list, and the initial value of the tmpIndex attribute of each element is equal to the srcIndex value of the element.

[0062] Step 206: Based on the element list, modify the sorting state value of at least one element to determine the target sorting state value of each element in the element list.

[0063] Among them, the sorting state value of at least one element is corrected with reference to the arrangement order of each element in the element list, and the optimal sorting value update scheme is calculated. In this process, the sorting state value will be adjusted according to the current sorting state. The server adjusts the sorting state value of each element so that the elements arranged at the front of the element list have smaller sorting state values ​​and the elements arranged at the back have larger sorting state values. The target sorting state value refers to the corrected sorting state value that conforms to the arrangement order of the element list.

[0064] In an optional implementation, the correction process includes: randomly selecting at least two elements (assuming they are fixed elements) that conform to the rule from the element list, conforming to the rule means: the sorting state value of the fixed element arranged in front is less than the sorting state value of the fixed element arranged in the back, and the difference between the sorting state values ​​of the two fixed elements is greater than a certain value (this parameter can be set according to the situation, for example, set to the total number of elements in the element list); according to the sorting state values ​​of the at least two selected fixed elements, the sorting state values ​​of other elements in the element list are adjusted. For an element located between two fixed elements, if the sorting state value of the element is between the sorting state values ​​of the two fixed elements, no adjustment is required; if the sorting state value of the element is greater than the sorting state values ​​of the two fixed elements at the same time, or less than the sorting state values ​​of the two fixed elements at the same time, the sorting state value of the element is adjusted to a value between the sorting state values ​​of the two fixed elements.

[0065] In an optional implementation, N rounds of corrections are performed based on the element list (N is an integer greater than or equal to 1), and each round corrects only the sorting state value of one element, which is the element in the element list whose sorting state value and the arrangement order are least matched. After N rounds of corrections, the sorting state value that conforms to the arrangement order of the element list is determined as the target sorting state value of each element in the element list.

[0066] Step 208: Filter out target elements whose original sorting values ​​are inconsistent with the target sorting state values.

[0067] Step 210: Write the target sorting state value of the target element as an updated sorting value into the database according to the element identifier of the target element.

[0068] Among them, elements whose srcIndex is not equal to tmpIndex are filtered out, the target elements whose sorting values ​​need to be adjusted this time are determined, and the tmpIndex of each target element is updated into the database as the final sorting value. Specifically, the target sorting state value of the target element is updated into the sorting field corresponding to the element identifier of the target element in the database.

[0069] It is understandable that the server recalculates the sort value in memory and only updates the sort value of the changed element in the database, without changing the sort value of all elements in the database, thus reducing database operations. Batch changes are supported, and user operations are simple: users only need to sort all elements on the interface and submit them to the server, which will automatically calculate the sort value based on the program and write it to the database.

[0070] In the above-mentioned list reordering method, a reordered element list is received; the element list includes multiple elements arranged in order, each element corresponds to an element identifier and an original sort value; a sort state value is added to each element in the element list; the initial value of the sort state value of each element is consistent with the original sort value corresponding to the element; based on the element list, the sort state value of at least one element is corrected to determine the target sort state value of each element in the element list; the target element whose original sort value is inconsistent with the target sort state value is screened out; according to the element identifier of the target element, the target sort state value of the target element is written into the database as the updated sort value. Among them, even if the front end modifies the sort value of multiple elements, it only needs to submit a request once, which can be reflected in the same reordered element list. By adding the sort state value and correcting it, the optimal sort value update scheme can be calculated, and only the changed sort value is written into the database, reducing the write operation to the database. Through the above-mentioned method, the number of submissions of back-end requests can be reduced, reducing network pressure; the number of updates to data in the database can also be reduced, saving database resources; and thus improving the efficiency of sort value adjustment.

[0071] In an exemplary embodiment, Figure 3 As shown, step 206 includes:

[0072] Step 302: Calculate the revised score of each element according to the element list and the current ranking status value of each element.

[0073] The correction score is used to evaluate the matching degree between the element's sorting state value and the arrangement order. The lower the correction score, the higher the matching degree between the element's sorting state value and the arrangement order, and the higher the correction score, the lower the matching degree between the element's sorting state value and the arrangement order.

[0074] Step 304, determining whether the revised score of each element is equal to a preset value.

[0075] The preset value is used to evaluate whether the sorting state value of the element matches the arrangement order. If the modified score of an element is equal to the preset value, it indicates that the sorting state value of the element matches the arrangement order; if the modified score of an element is not equal to the preset value, it indicates that the sorting state value of the element does not match the arrangement order.

[0076] In an optional implementation, the correction score is a left correction score, and the preset value is 0. The left correction score is used to indicate the number of elements in the element list that are on the left side of the current element and have a larger sorting state value than the current element. If the left correction scores of all elements are 0, it indicates that the sorting state value of each element matches the arrangement order.

[0077] In an optional implementation, the correction score is a right correction score, and the preset value is 0. The right correction score is used to indicate the number of elements in the element list that are to the right of the current element and have a smaller sorting state value than the current element. If the right correction scores of all elements are 0, it indicates that the sorting state value of each element matches the arrangement order.

[0078] In an optional implementation, the correction score is a left correction score and a right correction score, and the preset value is 0. The left correction score is used to indicate the number of elements in the element list that are on the left side of the current element and have a larger sorting state value than the current element, and the right correction score is used to indicate the number of elements in the element list that are on the right side of the current element and have a smaller sorting state value than the current element. If the left correction score and the right correction score of all elements are 0, it indicates that the sorting state value of each element matches the arrangement order.

[0079] Step 306: If the revised score of each element is equal to the preset value, the current sorting state value of each element is determined as the target sorting state value of each element in the element list.

[0080] When the sorting state value of each element matches the arrangement order, the current sorting state value is output as the corrected target sorting state value.

[0081] Step 308: If the correction score of at least one element is not equal to the preset value, then determine the element to be corrected from the multiple elements according to the correction score.

[0082] If the sorting state value of at least one element does not match the arrangement order, the sorting state value needs to be corrected. In an optional implementation, the element with the highest correction score is determined as the element to be corrected. The element with the lowest correction score can also be determined as the element to be corrected. The element to be corrected can be one element or multiple elements.

[0083] Step 310, modifying the sorting state value of the element to be modified.

[0084] Optionally, based on the sorting of the element to be corrected in the element queue, it is analyzed whether the current sorting state value of the element to be corrected is too low or too high; if the analysis determines that the current sorting state value of the element to be corrected is too low, the sorting state value of the element to be corrected is increased; if the analysis determines that the current sorting state value of the element to be corrected is too high, the sorting state value of the element to be corrected is reduced.

[0085] Step 312, return to execute step 302.

[0086] After this correction, the correction score is calculated again based on the corrected sorting state value, and the matching degree between the sorting state value of the element and the arrangement order is re-evaluated. The loop is executed multiple times until the correction score of each element is equal to the preset value, and the corrected sorting state value of the current time is output as the target sorting state value.

[0087] In this embodiment, by calculating the revised scores in multiple cycles and revising the sorting state values ​​of the elements, the optimal solution can be gradually approached, thereby improving the accuracy of the revised sorting state values.

[0088] In an exemplary embodiment, the correction score includes a left correction score and a right correction score; step 302 includes: for each element in the element list, starting with the current element, traversing to the first element in the element list, recording the number of first elements whose traversed sorting state values ​​are not less than the current element, and setting the number of first elements as the left correction score of the current element; starting with the current element, traversing to the last element in the element list, recording the number of second elements whose traversed sorting state values ​​are not greater than the current element, and setting the number of second elements as the right correction score of the current element.

[0089] Among them, the left correction score leftFixScore and the right correction score rightFixScore of each element are calculated, and the scoring rules are:

[0090] ①The initial values ​​of leftFixScore and rightFixScore are both 0.

[0091] ② Traverse from the current element to the first element in the list, and determine whether the tmpIndex of the traversed element is greater than or equal to the tmpIndex of the current element. Every time an element that meets the conditions is traversed, the leftFixScore of the current element is increased by 1.

[0092] ③ Traverse from the current element to the last element in the list, and determine whether the tmpIndex of the traversed element is less than or equal to the tmpIndex of the current element. Every time an element that meets the conditions is traversed, the rightFixScore of the current element is increased by 1.

[0093] The element list is traversed in ascending order, the traversed element is taken as the current element, and the left fix score leftFixScore and the right fix score rightFixScore are calculated for the current element based on the above-mentioned scoring rule.

[0094] In an exemplary embodiment, an element to be corrected is determined from multiple elements based on the correction scores, including: calculating the sum of the left correction score and the right correction score of each element to obtain the total score of each element; and determining the element with the highest total score among the multiple elements as the element to be corrected.

[0095] Among them, the higher the score, the more unreasonable the element's tmpIndex is and the lower the matching degree between the sorting status value and the arrangement order is, and its tmpIndex value needs to be corrected. Therefore, the logic of selecting the elements to be corrected is: calculate the sum of the leftFixScore and the rightFixScore of each element, and select the element with the largest sum as the element to be corrected.

[0096] In an optional implementation, one or more elements with the highest total score are determined as elements to be corrected, and the one or more elements are corrected simultaneously. Optionally, one element is selected again from the multiple elements with the highest total score as the element to be corrected.

[0097] In an exemplary embodiment, the method also includes: if there are multiple elements with the highest total score among multiple elements, then the non-latest revised elements among the elements with the highest total score are determined as elements to be revised; non-latest revised elements refer to elements that have been revised before and are not the most recent revision; if there are multiple non-latest revised elements among the elements with the highest total score, then the element closest to the first element or the last element among the multiple non-latest revised elements is determined as the element to be revised; if none of the multiple elements with the highest total score have been revised, then the element closest to the first element or the last element among the elements with the highest total score is determined as the element to be revised.

[0098] In the process of executing multiple cycles, the correction information of each element is recorded. The correction information can be the correction round, marking the round in which the element is corrected. For example, the correction information of element A is 1 and 4, indicating that element A is corrected in the first round and the fourth round. The correction information can also be the number of corrections and the correction time.

[0099] In the specific implementation, the logic for selecting the elements to be modified is:

[0100] ① Calculate the sum of leftFixScore and rightFixScore of each element, and select the element with the largest sum.

[0101] ② If there are multiple elements with the largest sum, give priority to the elements that have been modified and not the most recent modification (you can select based on the modification information of each element). Once modified means that the sorting status value of the element has been changed at least once after the initial setting. Selecting based on this item can narrow the scope of change as much as possible without changing the sorting status values ​​of all elements. Not the most recent modification means that it is not the element that was modified in the last round. Selecting based on this item can increase the diversity of modifications and improve the possibility of finding the optimal solution.

[0102] ③ If there are multiple elements with the largest sum that have been corrected and are not the most recent ones, the element closest to the first position or the element closest to the last position will be given priority.

[0103] ④ If there are multiple elements with the largest sum, and these elements are all uncorrected elements, the element closest to the first position or the element closest to the last position is selected first. If the kth time you encounter ③ or ④, select the element closest to the first position. If the k+1th time you encounter ③ or ④, select the element closest to the last position. The rotation is in turn, and k is an integer greater than or equal to 1.

[0104] In an exemplary embodiment, step 310 includes: if the element to be corrected is the first element in the element list, determining the current minimum sorting state value among the multiple elements, and taking the product of the minimum sorting state value and the preset coefficient as the corrected sorting state value of the element to be corrected; if the element to be corrected is the last element in the element list, determining the current maximum sorting state value among the multiple elements, and taking the sum of the maximum sorting state value and the preset additional value as the corrected sorting state value of the element to be corrected; if the element to be corrected is the middle element in the element list, taking the average value of the current sorting state values ​​of the adjacent elements of the element to be corrected as the corrected sorting state value of the element to be corrected.

[0105] Among them, the new tmpIndex value of the element to be corrected is calculated, and the calculation logic is as follows:

[0106] ① If the element to be corrected is at the first place in the list, calculate the product of the smallest tmpIndex in the list and the preset coefficient p, and round it down. The resulting number is used as the new tmpIndex of the element to be corrected, so that the sorting state value of the element at the first place in the list is the smallest. p is a parameter set in advance and can be adjusted according to actual conditions, 0<p<1. For example, p=0.5, take the average value of the smallest tmpIndex in the list as the new tmpIndex of the element to be corrected.

[0107] ② If the element to be corrected is at the end of the list, the sum of the largest tmpIndex in the list and the preset additional value r is calculated, and the resulting number is used as the new tmpIndex of the element to be corrected, so that the sorting state value of the element at the end of the list is the smallest. r is a parameter set in advance and can be adjusted according to actual conditions, r>1. For example, r=1000, take the largest tmpIndex+1000 in the list as the new tmpIndex of the element to be corrected.

[0108] ③ If the element to be corrected is located elsewhere in the list, calculate the average of the tmpIndex of the two adjacent elements of the element to be corrected, round it down, and use the resulting number as the new tmpIndex of the element to be corrected.

[0109] In an exemplary embodiment, before step 202, the method further includes: receiving an element list request; querying corresponding data in a database according to the element list request; generating an initial element list according to the queried data, and providing feedback on the initial element list; the initial element list includes a plurality of elements arranged in the original order, and each element corresponds to an element identifier and an original sort value.

[0110] Among them, the client sends an element list request to the server; the server queries data in the database and returns the data; the client's user interface displays the initial element list; the user adjusts the order of elements through the user interface and submits the reordered element list; the server receives the reordered element list and updates the sorting value in the database according to the aforementioned steps 202 to 210 to achieve list reordering.

[0111] In an exemplary embodiment, the list reordering method includes the following steps:

[0112] 1. After the front end adjusts the order of the elements in the list, it submits the sorted list of elements to the back end at one time. Each element in the list contains the following key attributes:

[0113] (1) Element ID, which is the unique identifier of the element in the database;

[0114] (2) srcIndex: original sort value, integer type. The smaller the value, the earlier it is, and vice versa.

[0115] 2. After receiving the reordered element list, the backend calculates the optimal sort value update scheme through the following algorithm:

[0116] (1) Add a tmpIndex attribute to each element in the element list. The initial value of this attribute is equal to srcIndex.

[0117] (2) Traverse the element list in ascending order and calculate the left fix score leftFixScore and right fix score rightFixScore of each element. The scoring rule is:

[0118] ①The initial values ​​of leftFixScore and rightFixScore are both 0.

[0119] ② Traverse from the current element to the first element in the list, and determine whether the tmpIndex of the traversed element is greater than or equal to the tmpIndex of the current element. Every time an element that meets the conditions is traversed, the leftFixScore of the current element is increased by 1.

[0120] ③ Traverse from the current element to the last element in the list, and determine whether the tmpIndex of the traversed element is less than or equal to the tmpIndex of the current element. Every time an element that meets the conditions is traversed, the rightFixScore of the current element is increased by 1.

[0121] (3) Select elements with unreasonable sorting. The selection logic is as follows:

[0122] ① Calculate the sum of leftFixScore and rightFixScore of each element, and select the element with the largest sum. The higher the score, the more unreasonable the tmpIndex of the element.

[0123] ② If there are multiple elements with the largest sum, the element that has been modified before and not the most recent one will be given priority.

[0124] ③ If there are multiple elements with the largest sum that have been corrected and are not the most recent ones, the element closest to the first position or the element closest to the last position will be given priority.

[0125] ④ If there are multiple elements with the largest sum, and these elements are all uncorrected elements, the element closest to the first position or the element closest to the last position is selected first. If the kth time you encounter ③ or ④, select the element closest to the first position. If the k+1th time you encounter ③ or ④, select the element closest to the last position. The rotation is in turn, and k is an integer greater than or equal to 1.

[0126] (4) Calculate the new tmpIndex value of the selected element. The calculation logic is as follows:

[0127] ① If the element to be corrected is at the first place in the list, take the average of the smallest tmpIndex in the list and round it down. The resulting number is used as the new tmpIndex of the element to be corrected.

[0128] ② If the element to be corrected is at the end of the list, take the largest tmpIndex in the list + 1000, and use the resulting number as the new tmpIndex of the element to be corrected.

[0129] ③ If the element to be corrected is located elsewhere in the list, calculate the average of the tmpIndex of the two adjacent elements of the element to be corrected, round it down, and use the resulting number as the new tmpIndex of the element to be corrected.

[0130] (5) Repeat steps (2) to (4) until the leftFixScore and rightFixScore values ​​of all elements are 0, and output the optimal sort value update scheme, which includes the latest tmpIndex of each element.

[0131] 3. According to the optimal sort value update plan, filter out the elements whose tmpIndex and srcIndex are not equal, and update the tmpIndex of these elements as the final sort value to the database.

[0132] By adopting the method of this embodiment, there is no need to change the sorting values ​​of all elements. Only minimal changes are required to achieve reordering of multiple elements, thereby reducing the pressure on database write operations.

[0133] In an exemplary embodiment, in combination with Figure 4 Table 1, the list reordering method provided in this application is illustrated by way of example. Table 1 is a numerical example of the elements to be sorted in the database table.

[0134] Table 1:

[0135]

[0136] The list reordering method includes the following steps:

[0137] 1. The page requests the element list from the backend and requests it to be sorted in ascending order of the sorting value of the elements.

[0138] 2. The backend program queries and sorts the data in the database and returns the data in the following format:

[0139] {

[0140] "list":

[0141] {"id": 4, "name": "Green", "index": 1500},

[0142] {"id": 2, "name": "Orange", "index": 2000},

[0143] {"id": 8, "name": "Black", "index": 2300},

[0144] {"id": 1, "name": "Red", "index": 3500},

[0145] {"id": 10, "name": "Grey", "index": 3700},

[0146] {"id": 7, "name": "Purple", "index": 4600},

[0147] {"id": 5, "name": "Cyan", "index": 5500},

[0148] {"id": 6, "name": "Blue", "index": 6000},

[0149] {"id": 9, "name": "White", "index": 9000},

[0150] {"id": 3, "name": "Yellow", "index": 9200}

[0152] }

[0153] The page is directly displayed in the order of elements in the data structure, and the result is [green, orange, black, red, gray, purple, cyan, blue, white, yellow].

[0154] 3. The user adjusts the order of elements and submits the adjusted list of elements; assume that the user adjusts the list of elements to [red, orange, yellow, green, cyan, blue, purple, black, white, gray], then the submitted data structure is:

[0155] {

[0156] "list":

[0157] {"id": 1, "name": "red", "index": 3500},

[0158] {"id": 2, "name": "orange", "index": 2000},

[0159] {"id": 3, "name": "yellow", "index": 9200},

[0160] {"id": 4, "name": "green", "index": 1500},

[0161] {"id": 5, "name": "cyan", "index": 5500},

[0162] {"id": 6, "name": "blue", "index": 6000},

[0163] {"id": 7, "name": "purple", "index": 4600},

[0164] {"id": 8, "name": "black", "index": 2300},

[0165] {"id": 9, "name": "white", "index": 9000},

[0166] {"id": 10, "name": "gray", "index": 3700}

[0168] }

[0169] 4. The back-end program recalculates the sorting values of each element: ​​

[0170] (1) ID is the unique identifier of the element, srcIndex is the original sort value of the element, and the initial value of tmpIndex is equal to srcIndex.

[0171] (2) Traverse the element list in ascending order, as shown in Table 2, and calculate the left fix score leftFixScore and the right fix score rightFixScore of each element.

[0172] Table 2:

[0173]

[0174] Taking the element with ID=5 as an example, tmpIndex=5500. There is only one element on its left (ID=3) whose tmpIndex is not less than it, and there are three elements on its right (ID=7, 8, 10) whose tmpIndex is not greater than it. Therefore, the leftFixScore=1 and rightFixScore=3 of the element with ID=5 are, and the sum of these two fix scores is fixScore=4.

[0175] (3) Among these 10 elements, the element with ID = 3 has the largest fixScore, so the first round of correction process recalculates its tmpIndex, tmpIndex = (2000 + 1500) / 2 = 1750.

[0176] (4) Recalculate the corrected score as shown in Table 3.

[0177] Table 3:

[0178]

[0179] (5) In the second round of correction, the element with ID = 8 has the largest fixScore. Its tmpIndex is recalculated, tmIndex = (4600 + 9000) / 2 = 6800.

[0180] (6) As shown in Table 4, the revised scores were calculated for the third time.

[0181] Table 4:

[0182]

[0183] (7) In the third round of correction, the element with ID = 10 has the largest fixScore. Its tmpIndex is recalculated, tmpIndex = 9000 + 1000 = 10000.

[0184] (8) As shown in Table 5, the fourth calculation of the revised score.

[0185] Table 5:

[0186]

[0187] (9) In the fourth round of correction, the elements with ID = 1, 2, 3, 4 have the largest fixScore. First, take the first one on the left and recalculate its tmpIndex, tmpIndex = 1500 / 2 = 750.

[0188] (10) As shown in Table 6, the revised scores were calculated for the fifth time.

[0189] Table 6:

[0190]

[0191] (11) In the fifth round of correction, the elements with ID = 2, 3, 4, and 7 all have the largest fixScore. This time, we take the first one on the right and recalculate its tmpIndex, tmpIndex = (6000 + 6800) / 2 = 6400.

[0192] (12) As shown in Table 7, the revised scores were calculated for the sixth time.

[0193] Table 7:

[0194]

[0195] (13) In the sixth round of correction, the elements with ID = 2, 3, and 4 have the largest fixScore. This time, we take the first one on the left and recalculate its tmpIndex, tmpIndex = (750 + 1750) / 2 = 1250.

[0196] (14) As shown in Table 8, the revised scores were calculated for the seventh time.

[0197] Table 8:

[0198]

[0199] (15) During the seventh round of correction, the elements with ID=3 and 4 have the largest fixScore. Since ID=3 has been corrected before and ID=4 has not, and ID=3 was not the last corrected, ID=3 is corrected first, and tmpIndex=(1250+1500) / 2=1375.

[0200] (16) As shown in Table 9, the eighth calculation of the revised score.

[0201] Table 9:

[0202]

[0203] As can be seen from the above table (9), the correction score of each element is 0, indicating that the optimal sorting value has been calculated. By comparing srcIndex and tmpIndex, it can be concluded that the sorting values ​​of the six elements ID = 1, 2, 3, 7, 8, 10 need to be changed.

[0204] 5. The backend program updates the latest sort values ​​of the elements whose sort values ​​have changed to the database. The latest sort values ​​tmpIndex of the six elements with ID = 1, 2, 3, 7, 8, and 10 are updated to the database. Finally, the data saved in the database is shown in Table 10 below, and the re-sorting is completed.

[0205] Table 10:

[0206]

[0207] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0208] Based on the same inventive concept, the embodiment of the present application also provides a list reordering device for implementing the list reordering method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more list reordering device embodiments provided below can refer to the limitations of the list reordering method above, and will not be repeated here.

[0209] In an exemplary embodiment, Figure 5 As shown, a list reordering device is provided, comprising:

[0210] The receiving module 502 is used to receive a reordered element list; the element list includes a plurality of elements arranged in sequence, and each element corresponds to an element identifier and an original sort value.

[0211] The attribute adding module 504 is used to add a sorting state value to each element in the element list; the initial value of the sorting state value of each element is consistent with the original sorting value corresponding to the element.

[0212] The correction module 506 is used to correct the sorting state value of at least one element based on the element list, and determine the target sorting state value of each element in the element list.

[0213] The sorting module 508 is used to filter out target elements whose original sorting values ​​are inconsistent with the target sorting state values; and write the target sorting state values ​​of the target elements as updated sorting values ​​into the database according to the element identifiers of the target elements.

[0214] In the above-mentioned list reordering device, a reordered element list is received; the element list includes multiple elements arranged in order, each element corresponds to an element identifier and an original sort value; a sort state value is added to each element in the element list; the initial value of the sort state value of each element is consistent with the original sort value corresponding to the element; based on the element list, the sort state value of at least one element is corrected to determine the target sort state value of each element in the element list; the target element whose original sort value is inconsistent with the target sort state value is screened out; according to the element identifier of the target element, the target sort state value of the target element is written into the database as the updated sort value. Among them, even if the front end modifies the sort value of multiple elements, it only needs to submit a request once, which can be reflected in the same reordered element list. By adding the sort state value and correcting it, the optimal sort value update scheme can be calculated, and only the changed sort value is written into the database, reducing the write operation to the database. Through the above-mentioned method, the number of submissions of back-end requests can be reduced, reducing network pressure; the number of updates to data in the database can also be reduced, saving database resources; and thus improving the efficiency of sort value adjustment.

[0215] In an exemplary embodiment, the correction module 506 is also used to calculate the correction score of each element based on the element list and the current sorting state value of each element; determine whether the correction score of each element is equal to a preset value; if the correction score of each element is equal to the preset value, determine the current sorting state value of each element as the target sorting state value of each element in the element list; if the correction score of at least one element is not equal to the preset value, determine the element to be corrected from multiple elements based on the correction score; correct the sorting state value of the element to be corrected; return to execute the step of calculating the correction score of each element based on the element list and the current sorting state value of each element.

[0216] In an exemplary embodiment, the correction module 506 is also used to, for each element in the element list, traverse from the current element as the starting element to the first element in the element list, record the number of first elements whose traversed sorting state values ​​are not less than the current element, and set the number of first elements as the left correction score of the current element; traverse from the current element as the starting element to the last element in the element list, record the number of second elements whose traversed sorting state values ​​are not greater than the current element, and set the number of second elements as the right correction score of the current element.

[0217] In an exemplary embodiment, the correction module 506 is further configured to calculate the sum of the left correction score and the right correction score of each element to obtain a total score of each element; and determine the element with the highest total score among the multiple elements as the element to be corrected.

[0218] In an exemplary embodiment, the correction module 506 is also used to, if there are multiple elements with the highest total score among multiple elements, determine the non-latest corrected elements among the elements with the highest total score as elements to be corrected; the non-latest corrected elements refer to elements that have been corrected before and are not the most recent correction; if there are multiple non-latest corrected elements among the elements with the highest total score, then the element closest to the first element or the last element among the multiple non-latest corrected elements is determined as the element to be corrected; if none of the multiple elements with the highest total score have been corrected, then the element closest to the first element or the last element among the elements with the highest total score is determined as the element to be corrected.

[0219] In an exemplary embodiment, the correction module 506 is also used to determine the current minimum sorting state value among multiple elements if the element to be corrected is the first element in the element list, and use the product of the minimum sorting state value and the preset coefficient as the corrected sorting state value of the element to be corrected; if the element to be corrected is the last element in the element list, determine the current maximum sorting state value among multiple elements, and use the sum of the maximum sorting state value and the preset additional value as the corrected sorting state value of the element to be corrected; if the element to be corrected is the middle element in the element list, then use the average value of the current sorting state values ​​of the adjacent elements of the element to be corrected as the corrected sorting state value of the element to be corrected.

[0220] In an exemplary embodiment, the receiving module 502 is also used to receive an element list request; according to the element list request, the corresponding data is queried in the database; an initial element list is generated according to the queried data, and feedback is given to the initial element list; the initial element list includes multiple elements arranged in the original order, and each element corresponds to an element identifier and an original sort value.

[0221] Each module in the above-mentioned list reordering device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.

[0222] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 6 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a list reordering method is implemented.

[0223] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0224] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the following steps when executing the computer program: receiving a reordered element list; the element list includes a plurality of elements arranged in order, each element corresponding to an element identifier and an original sort value; adding a sort state value for each element in the element list; the initial value of the sort state value of each element is consistent with the original sort value corresponding to the element; based on the element list, correcting the sort state value of at least one element to determine the target sort state value of each element in the element list; screening out target elements whose original sort values ​​are inconsistent with the target sort state values; and writing the target sort state value of the target element as an updated sort value into a database according to the element identifier of the target element.

[0225] In one embodiment, when the processor executes the computer program, the following steps are also implemented: calculating a revised score for each element based on the element list and the current sorting state value of each element; determining whether the revised score of each element is equal to a preset value; if the revised score of each element is equal to the preset value, determining the current sorting state value of each element as the target sorting state value of each element in the element list; if the revised score of at least one element is not equal to the preset value, determining an element to be revised from multiple elements based on the revised score; revising the sorting state value of the element to be revised; and returning to execute the step of calculating the revised score of each element based on the element list and the current sorting state value of each element.

[0226] In one embodiment, the processor further implements the following steps when executing the computer program: for each element in the element list, starting with the current element, traversing to the first element in the element list, recording the number of first elements whose traversed sorting state values ​​are not less than the current element, and setting the number of first elements as the left revised score of the current element; starting with the current element, traversing to the last element in the element list, recording the number of second elements whose traversed sorting state values ​​are not greater than the current element, and setting the number of second elements as the right revised score of the current element.

[0227] In one embodiment, when the processor executes the computer program, the following steps are also implemented: calculating the sum of the left correction score and the right correction score of each element to obtain the total score of each element; and determining the element with the highest total score among multiple elements as the element to be corrected.

[0228] In one embodiment, the processor further implements the following steps when executing the computer program: if there are multiple elements with the highest total score among multiple elements, then the non-latest revised elements among the elements with the highest total score are determined as elements to be revised; non-latest revised elements refer to elements that have been revised before and are not the most recent revision; if there are multiple non-latest revised elements among the elements with the highest total score, then the element closest to the first element or the last element among the multiple non-latest revised elements is determined as the element to be revised; if none of the multiple elements with the highest total score have been revised, then the element closest to the first element or the last element among the elements with the highest total score is determined as the element to be revised.

[0229] In one embodiment, when the processor executes the computer program, the following steps are also implemented: if the element to be corrected is the first element in the element list, the current minimum sorting state value among the multiple elements is determined, and the product of the minimum sorting state value and the preset coefficient is used as the corrected sorting state value of the element to be corrected; if the element to be corrected is the last element in the element list, the current maximum sorting state value among the multiple elements is determined, and the sum of the maximum sorting state value and the preset additional value is used as the corrected sorting state value of the element to be corrected; if the element to be corrected is the middle element in the element list, the average value of the current sorting state values ​​of the adjacent elements of the element to be corrected is used as the corrected sorting state value of the element to be corrected.

[0230] In one embodiment, when the processor executes the computer program, the following steps are also implemented: receiving an element list request; querying corresponding data in a database according to the element list request; generating an initial element list according to the queried data, and providing feedback on the initial element list; the initial element list includes multiple elements arranged in the original order, and each element corresponds to an element identifier and an original sort value.

[0231] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: receiving a reordered element list; the element list includes a plurality of elements arranged in order, each element corresponding to an element identifier and an original sort value; adding a sort state value for each element in the element list; the initial value of the sort state value of each element is consistent with the original sort value corresponding to the element; based on the element list, the sort state value of at least one element is corrected to determine the target sort state value of each element in the element list; screening out target elements whose original sort values ​​are inconsistent with the target sort state values; and writing the target sort state value of the target element as an updated sort value into a database according to the element identifier of the target element.

[0232] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: calculating a revised score for each element based on the element list and the current sorting state value of each element; determining whether the revised score of each element is equal to a preset value; if the revised score of each element is equal to the preset value, determining the current sorting state value of each element as the target sorting state value of each element in the element list; if the revised score of at least one element is not equal to the preset value, determining an element to be revised from multiple elements based on the revised score; revising the sorting state value of the element to be revised; and returning to execute the step of calculating the revised score of each element based on the element list and the current sorting state value of each element.

[0233] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: for each element in the element list, starting with the current element, traversing to the first element in the element list, recording the number of first elements whose traversed sorting state values ​​are not less than the current element, and setting the number of first elements as the left correction score of the current element; starting with the current element, traversing to the last element in the element list, recording the number of second elements whose traversed sorting state values ​​are not greater than the current element, and setting the number of second elements as the right correction score of the current element.

[0234] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: calculating the sum of the left correction score and the right correction score of each element to obtain the total score of each element; and determining the element with the highest total score among multiple elements as the element to be corrected.

[0235] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: if there are multiple elements with the highest total score among multiple elements, then the non-latest revised elements among the elements with the highest total score are determined as elements to be revised; non-latest revised elements refer to elements that have been revised before and are not the most recent revision; if there are multiple non-latest revised elements among the elements with the highest total score, then the element closest to the first element or the last element among the multiple non-latest revised elements is determined as the element to be revised; if none of the multiple elements with the highest total score have been revised, then the element closest to the first element or the last element among the elements with the highest total score is determined as the element to be revised.

[0236] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: if the element to be corrected is the first element in the element list, the current minimum sorting state value among the multiple elements is determined, and the product of the minimum sorting state value and the preset coefficient is used as the corrected sorting state value of the element to be corrected; if the element to be corrected is the last element in the element list, the current maximum sorting state value among the multiple elements is determined, and the sum of the maximum sorting state value and the preset additional value is used as the corrected sorting state value of the element to be corrected; if the element to be corrected is the middle element in the element list, the average value of the current sorting state values ​​of the adjacent elements of the element to be corrected is used as the corrected sorting state value of the element to be corrected.

[0237] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: receiving an element list request; querying corresponding data in a database according to the element list request; generating an initial element list according to the queried data, and providing feedback on the initial element list; the initial element list includes multiple elements arranged in the original order, and each element corresponds to an element identifier and an original sort value.

[0238] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0239] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0240] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0241] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A list reordering method, characterized in that: The method comprises: Receiving a reordered element list; the element list includes a plurality of elements arranged in sequence, each element corresponding to an element identifier and an original sort value; Adding a sorting state value to each element in the element list; the initial value of the sorting state value of each element is consistent with the original sorting value corresponding to the element; Based on the element list, modifying the sorting state value of at least one element to determine a target sorting state value for each element in the element list; Filter out target elements whose original sorting values ​​are inconsistent with the target sorting status values; According to the element identifier of the target element, the target sorting state value of the target element is written into the database as an updated sorting value.

2. The method according to claim 1, characterized in that The step of modifying the sorting state value of at least one element based on the element list to determine the target sorting state value of each element in the element list includes: Calculate a modified score for each element based on the element list and the current ranking status value of each element; Determine whether the modified score of each element is equal to the preset value; If the revised score of each element is equal to the preset value, the current ranking state value of each element is determined as the target ranking state value of each element in the element list; If the correction score of at least one element is not equal to the preset value, determining an element to be corrected from the multiple elements according to the correction score; Correcting the sorting state value of the element to be corrected; Return to execute the step of calculating the modified score of each element based on the element list and the current sorting status value of each element.

3. The method according to claim 2, characterized in that The correction score includes a left correction score and a right correction score; The step of calculating the modified score of each element according to the element list and the current sorting state value of each element comprises: For each element in the element list, starting from the current element, traverse toward the first element in the element list, record the first element number whose sorting state value is not less than the current element, and set the first element number as the left corrected score of the current element; Taking the current element as the starting element, traverse toward the last element of the element list, record the number of second elements whose sorting state values ​​are not greater than the current element, and set the number of second elements as the right corrected score of the current element.

4. The method according to claim 3, characterized in that Determining the element to be corrected from the multiple elements according to the correction score includes: Calculate the sum of the left-corrected score and the right-corrected score of each element to get the total score of each element; The element with the highest total score among the multiple elements is determined as the element to be corrected.

5. The method according to claim 4, characterized in that The method further comprises: If there are multiple elements with the highest total score among the multiple elements, then the non-latest revised elements among the elements with the highest total score are determined as the elements to be revised; the non-latest revised elements refer to elements that have been revised before but not the most recent revision; If there are multiple non-latest revised elements among the elements with the highest total score, the element closest to the first element or the last element among the multiple non-latest revised elements is determined as the element to be revised; If the multiple elements with the highest total scores have not been corrected, then the element closest to the first element or the last element among the elements with the highest total scores is determined as the element to be corrected.

6. The method according to claim 2, characterized in that The step of modifying the sorting state value of the element to be modified includes: If the element to be corrected is the first element in the element list, determining the current minimum sorting state value among the multiple elements, and taking the product of the minimum sorting state value and a preset coefficient as the corrected sorting state value of the element to be corrected; If the element to be corrected is the last element in the element list, determining the current maximum sorting state value among the multiple elements, and taking the sum of the maximum sorting state value and the preset additional value as the corrected sorting state value of the element to be corrected; If the element to be corrected is the middle element of the element list, the average value of the current sorting state values ​​of the adjacent elements of the element to be corrected is used as the corrected sorting state value of the element to be corrected.

7. The method according to any one of claims 1 to 6, characterized in that Before receiving the reordered list of elements, the method further includes: Receive element list request; According to the element list request, query corresponding data in the database; An initial element list is generated according to the queried data, and feedback is provided to the initial element list; the initial element list includes a plurality of elements arranged in an original order, and each element corresponds to an element identifier and an original sort value.

8. A list reordering device, characterized in that: The device comprises: A receiving module, configured to receive a reordered element list; the element list includes a plurality of elements arranged in sequence, each element corresponding to an element identifier and an original sort value; An attribute adding module, used for adding a sorting state value to each element in the element list; the initial value of the sorting state value of each element is consistent with the original sorting value corresponding to the element; A correction module, used to correct the sorting state value of at least one element based on the element list, and determine the target sorting state value of each element in the element list; The sorting module is used to filter out target elements whose original sorting values ​​are inconsistent with the target sorting state values; and write the target sorting state values ​​of the target elements as updated sorting values ​​into the database according to the element identifiers of the target elements.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.