A method and device for sorting elements

By setting weights and position identifiers for user interface elements, and updating the weight of the target element after a drag operation, the problem of low efficiency of element sorting in the existing technology is solved, and efficient element sorting and data balance are achieved.

CN110362297BActive Publication Date: 2024-10-18BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201810251552.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-03-26
Publication Date
2024-10-18
Estimated Expiration
2038-03-26

AI Technical Summary

Technical Problem

In the prior art, when an element is dragged and dropped, all elements between the original position and the target position of the target element need to be moved, and then the position of the target element is modified, resulting in low efficiency.

Method used

By pre-setting the weight and position identifier for the elements of the user interface, when the user stops the drag operation, the weight of the target element is updated based on the weight of the current position identifier and the adjacent position identifier, thereby achieving element sorting and only updating the weight of the target element. Does not affect the position of other elements.

Benefits of technology

It achieves efficient and fast element sorting, avoids unnecessary element position movement, and ensures the balance of data intervals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110362297B_ABST
    Figure CN110362297B_ABST
Patent Text Reader

Abstract

The present invention discloses an element sorting method and device, and relates to the field of computer technology. A specific implementation of the method includes: when it is detected that the dragging operation on the target element of the user interface stops, the current position identifier of the target element is obtained; according to the weight of the element corresponding to the current position identifier and the weight of the element corresponding to its adjacent position identifier, the weight of the target element is updated; according to the updated weight, all elements of the user interface are sorted. This implementation method sets weights and position identifiers for the elements of the user interface in advance. When the user stops the dragging operation on the target element, the weight of the target element is updated according to the weight of the element corresponding to the current position identifier and its adjacent position identifier. Therefore, the present application only needs to update the weight of the target element to achieve element sorting, which is efficient and fast, and there is no need to move the positions of other elements affected by the sorting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to an element sorting method and device. Background Art

[0002] In some display lists of the application, users are allowed to customize the order of each element in the list by dragging and dropping. For example, there are six elements A, B, C, D, E, and F in the list, and they are displayed in the above order. The user can drag element E and drop it between elements A and B, and the display order of the list becomes A, E, B, C, D, F.

[0003] like Figure 1 As shown, when the prior art implements the above-mentioned element position change, it is necessary to pre-assign a number representing the order to each element. Assuming that the numbers corresponding to elements A to F are 1 to 6, if element E at the fifth position is to be moved to the second position, the order of the three elements B, C, and D needs to be moved back one position in turn, and then element E needs to be deleted from the original position, and then its order needs to be modified to 2.

[0004] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art: all elements between the original position of the target element and the target position need to be moved, and then the position of the target element is modified. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides an element sorting method and device, by pre-setting weights and position identifiers for elements of the user interface. When the user stops dragging the target element, the weight of the target element is updated according to the weights of the elements corresponding to the current position identifier and its adjacent position identifiers. This allows the present application to achieve element sorting by only updating the weight of the target element, which is efficient and fast and does not require moving the positions of other elements affected by the sorting.

[0006] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for sorting elements is provided.

[0007] An element sorting method according to an embodiment of the present invention comprises: when it is detected that the dragging operation on the target element of the user interface is stopped, obtaining the current position identifier of the target element; wherein each element of the user interface is provided with a weight and a position identifier set according to the weight; updating the weight of the target element according to the weight of the element corresponding to the current position identifier and the weight of the element corresponding to its adjacent position identifier; and sorting all elements of the user interface according to the updated weights.

[0008] Optionally, before the step of obtaining the current position identifier of the target element, it also includes: setting a unique weight for each element of the user interface, sorting all elements according to the size of the weight; and setting the position identifier for each element according to the weight sorting result.

[0009] Optionally, the weight of the target element is updated according to the weight of the element corresponding to the current position identifier and the weight of the element corresponding to its adjacent position identifier, including: if the current position identifier is smaller than the position identifier and is not the first position identifier, obtaining the weight of the element corresponding to the current position identifier and the weight of the element corresponding to the position identifier before the current position identifier; if the current position identifier is larger than the position identifier and is not the last position identifier, obtaining the weight of the element corresponding to the current position identifier and the weight of the element corresponding to the position identifier after the current position identifier; and using half of the sum of the two obtained weights as the new weight of the target element to update the weight of the target element.

[0010] Optionally, before the step of sorting all elements of the user interface according to the updated weights, it also includes: determining whether the current location identifier is the first location identifier or the last location identifier; if the current location identifier is the first location identifier, obtaining the weight of the element corresponding to the first location identifier, and using half of the obtained weight as the new weight of the target element to update the weight of the target element; if the current location identifier is the last location identifier, obtaining the weight of the element corresponding to the last location identifier, and using the sum of the obtained weight and a preset step size as the new weight of the target element to update the weight of the target element.

[0011] To achieve the above objective, according to one aspect of an embodiment of the present invention, an element sorting device is provided.

[0012] An element sorting device according to an embodiment of the present invention comprises: an acquisition module, for acquiring the current position identifier of the target element of the user interface when it is detected that the dragging operation on the target element of the user interface is stopped; wherein each element of the user interface is provided with a weight and a position identifier set according to the weight; an update module, for updating the weight of the target element according to the weight of the element corresponding to the current position identifier and the weight of the element corresponding to its adjacent position identifier; and a sorting module, for sorting all elements of the user interface according to the updated weights.

[0013] Optionally, the device further includes: a setting module, used to set a unique weight for each element of the user interface, sort all elements according to the weight; and set the position identifier for each element according to the weight sorting result.

[0014] Optionally, the update module is also used to: if the current position identifier is smaller than the position identifier and is not the first position identifier, obtain the weight of the element corresponding to the current position identifier and the weight of the element corresponding to the position identifier before the current position identifier; if the current position identifier is larger than the position identifier and is not the last position identifier, obtain the weight of the element corresponding to the current position identifier and the weight of the element corresponding to the position identifier after the current position identifier; and use half of the sum of the two obtained weights as the new weight of the target element to update the weight of the target element.

[0015] Optionally, the device also includes: a judgment and update module, used to judge whether the current location identifier is the first location identifier or the last location identifier; if the current location identifier is the first location identifier, then obtaining the weight of the element corresponding to the first location identifier, and using half of the obtained weight as the new weight of the target element to update the weight of the target element; and if the current location identifier is the last location identifier, then obtaining the weight of the element corresponding to the last location identifier, and using the sum of the obtained weight and a preset step size as the new weight of the target element to update the weight of the target element.

[0016] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device is provided.

[0017] An electronic device according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement an element sorting method according to an embodiment of the present invention.

[0018] To achieve the above objective, according to another aspect of the embodiments of the present invention, a computer readable medium is provided.

[0019] A computer-readable medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, an element sorting method according to an embodiment of the present invention is implemented.

[0020] One embodiment of the above invention has the following advantages or beneficial effects: by setting weights and position identifiers for elements of the user interface in advance, when the user stops dragging the target element, the weight of the target element is updated according to the weights of the elements corresponding to the current position identifier and its adjacent position identifiers, so that the present application only needs to update the weight of the target element to achieve element sorting, which is efficient and fast without moving the positions of other elements affected by the sorting; by setting weights and position identifiers for elements in advance, it is convenient to update the weight of the target element later to re-sort the elements of the user interface; after the dragging operation, half of the sum of the weights of the two elements before and after the target element is located in the area is used as the new weight, thereby ensuring the balance of data intervals.

[0021] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0023] Figure 1 It is a schematic diagram of the principle of the element sorting method in the prior art;

[0024] Figure 2 is a schematic diagram of main steps of an element sorting method according to an embodiment of the present invention;

[0025] Figure 3 is a schematic diagram of the main flow of the element sorting method according to an embodiment of the present invention;

[0026] Figure 4 is a schematic diagram of weight sorting results of an element sorting method according to an embodiment of the present invention;

[0027] Figure 5 is a schematic diagram of weight updating of an element sorting method according to an embodiment of the present invention;

[0028] Figure 6 is a schematic diagram of sorting results according to the element sorting method according to an embodiment of the present invention;

[0029] Figure 7 is a schematic diagram of main modules of an element sorting device according to an embodiment of the present invention;

[0030] Figure 8 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0031] Fig. 9 It is a schematic diagram of the structure of a computer device suitable for implementing the electronic device of the embodiment of the present invention. DETAILED DESCRIPTION

[0032] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0033] Figure 2 Schematic diagram of the main steps of the element sorting method according to an embodiment of the present invention. Figure 2 As shown, the element sorting method of the embodiment of the present invention mainly includes the following steps:

[0034] Step S201: When it is detected that the dragging operation on the target element of the user interface stops, the current position identifier of the target element is obtained; wherein each element of the user interface is set with a weight and a position identifier set according to the weight. The user drags an element of the user interface, and the element may be, for example, a desktop icon of the client, an item in a display list, etc. A position identifier is set in advance for each element of the user interface to uniquely identify the current order of each element. If the client detects that the user stops dragging the target element, the position identifier of the original element corresponding to the current location of the target element is obtained, and the position identifier is used as the current position identifier of the target element.

[0035] Step S202: Update the weight of the target element according to the weight of the element corresponding to the current position identifier and the weight of the element corresponding to its adjacent position identifier. Set a unique weight for each element of the user interface in advance, and sort all elements according to the weight. The result of the weight sorting is the current order of each element. If the current position identifier of the target element is smaller than its position identifier, it means that the target element needs to be sorted in front of its original position; if the current position identifier of the target element is larger than its position identifier, it means that the target element needs to be sorted behind its original position; half of the sum of the weights of the two elements before and after the target element after dragging is used as the new weight of the target element.

[0036] Step S203: Sort all elements of the user interface according to the updated weights. This step is the same as the rule of sorting all elements according to weights in step S202, that is, they are sorted in order from small to large or from large to small. The function of dragging and sorting the elements of the user interface can be realized through the above process.

[0037] Figure 3 FIG. 1 is a schematic diagram of the main flow of the element sorting method according to an embodiment of the present invention. Figure 3As shown, the element sorting method of the embodiment of the present invention is implemented by an element sorting device, which mainly includes the following steps:

[0038] Step S301: Set a unique weight for each element of the user interface, and sort all elements according to the weight. Add a weight attribute to each element of the user interface, and the attribute can be identified by weight. In the embodiment, a step is pre-set, and the value of the step is customized by the user according to the frequency of element sorting. If the sorting frequency is relatively high, the step can be designed to be larger, and if the sorting frequency is relatively low, the step can be designed to be smaller. When setting weights for elements, assuming that the weight of element 1 is set to 10 and the step is 10, the weight of element 2 is the weight of element 1 + step (i.e., 10+10=20), the weight of element 3 is the weight of element 2 + step (i.e., 20+10=30), and so on. When sorting elements, they can be sorted in order from large to small or from small to large.

[0039] Figure 4 Schematic diagram of weight sorting results of the element sorting method according to an embodiment of the present invention. Figure 4 As shown, there are 6 elements in the current user interface, namely element 1 to element 6, and the weights of each element are 10, 20, 30, 40, 50 and 60 respectively. They are sorted from small to large according to the weight (that is, the larger the weight, the later the order), and the resulting element order is element 1, element 2, element 3, element 4, element 5 and element 6.

[0040] Step S302: Set a position identifier for each element according to the weight sorting result. In this embodiment, the position identifier of the first element (ie, element 1) is set to 1, the position identifier of the second element (ie, element 2) is set to 2, and so on.

[0041] Step S303: when it is detected that the user performs a drag operation on the target element, the dragging track is obtained and the target element is dragged according to the dragging track. When the user performs a drag operation on an element, the client detects the dragging action and drags the element according to the obtained dragging track.

[0042] Step S304: When it is detected that the user stops dragging the target element, the current position identifier of the target element is obtained. Each element in the user interface occupies a regional position. The regional position where the target element is located when the dragging operation is stopped is obtained, and the position identifier of the original element at the regional position is used as the current position identifier of the target element. In a preferred embodiment, it is assumed that element 6 in the current user interface needs to be moved to the third regional position, that is, the position of element 3. When the client detects that element 6 is dragged to the regional position where element 3 is located, the position identifier 3 of element 3 is used as the current position identifier of element 6.

[0043] Step S305: Compare the current position identifier with the set position identifier. If the current position identifier is smaller than the position identifier, execute step S306; if the current position identifier is larger than the position identifier, execute step S309. The purpose of this step is to determine whether the element is sorted in front of or behind the original position. If it is sorted in front of the original position, it is sorted by dragging forward; if it is sorted behind the original position, it is sorted by dragging backward. In a preferred embodiment, assuming that element 6 needs to be moved to the third area position (i.e., sorted by dragging forward), the position identifier of element 6 is 6, and the current position identifier is 3. Since 3 is less than 6, execute step S306; assuming that element 1 needs to be moved to the fourth area position (i.e., sorted by dragging backward), the position identifier of element 1 is 1, and the current position identifier is 4. Since 4 is greater than 1, execute step S309.

[0044] Step S306: Determine whether the current position identifier is the first position identifier. If the current position identifier is the first position identifier, execute step S307; if the current position identifier is different from the first position identifier, execute step S308. The first position identifier is 1. In a preferred embodiment, if element 6 needs to be moved to the first regional position, execute step S307; if element 6 needs to be moved to other regional positions except the first regional position, execute step S308.

[0045] Step S307: Obtain the weight of the element corresponding to the first position identifier, and use half of the obtained weight as the new weight of the target element to update the weight of the target element, and execute step S312. If the position identifiers are set in order of weight from small to large (i.e., position identifiers with small weights are small, and position identifiers with large weights are large), then the new weight of the target element in this step can be any positive number smaller than the weight of the element corresponding to the first position identifier. However, since there may be new elements that need to be sorted in front of the target element in the future, in order to maintain the balance of the data interval, half of the weight of the element is taken as the new weight of the target element. In a preferred embodiment, the weight of element 1 is 10, and the weight of element 6 is 60. The weight of element 1, 10, is directly divided by 2 to obtain the new weight of element 6, 5, and then the weight of element 6 is updated from 60 to 5.

[0046] In another preferred embodiment, if in step S302 the position identifiers are set in order from large to small weights (i.e., the position identifier with large weights is small, and the position identifier with small weights is large), then the new weight of the target element in this step can be the sum of the weight of the element corresponding to the first position identifier and the preset step size.

[0047] Step S308: Obtain the weight of the element corresponding to the current position identifier and the weight of the element corresponding to the previous position identifier of the current position identifier, and use half of the sum of the two weights as the new weight of the target element to update the weight of the target element, and execute step S312. The new weight of the target element in this step and step S311 can be any positive number between the two weights obtained above, but since there may be new elements that need to be sorted between the target element and the two elements before and after it, in order to maintain the balance of the data interval, half of the sum of the two weights is taken as the new weight of the target element. In a preferred embodiment, assuming that element 6 needs to be moved to the third regional position, the original element of the third regional position is element 3, whose weight is 30, and the element of the second regional position is element 2, whose weight is 20, then the new weight of element 6 is (20+30) / 2=25, and then the weight of element 6 is updated from 60 to 25.

[0048] Figure 5 Schematic diagram of weight update of the element sorting method according to an embodiment of the present invention. Figure 5 As shown, the element 6 is moved from the last region position to the third region position, and the new weight of the element 6 is (20+30) / 2=25.

[0049] Step S309: Determine whether the current position identifier is the last position identifier. If the current position identifier is the last position identifier, execute step S310; if the current position identifier is different from the last position identifier, execute step S311. In a preferred embodiment, assuming that there are 6 elements in the current user interface, if element 1 needs to be moved to the 6th area position, execute step S310; if element 1 needs to be moved to other area positions except the 6th area position, execute step S311.

[0050] Step S310: Obtain the weight of the element corresponding to the last position identifier, and use the sum of the obtained weight and the preset step length as the new weight of the target element to update the weight of the target element, and execute step S312. If the position identifiers are set in order of weight from small to large (i.e., the position identifier with small weight is small, and the position identifier with large weight is large), then the new weight of the target element in this step can be any positive number greater than the weight of the element corresponding to the last position identifier. However, since there may be new elements that need to be sorted behind the target element in the future, in order to maintain the balance of the data interval, the sum of the weight of the element and the step length is taken as the new weight of the target element. In a preferred embodiment, the weight of element 6 is 60, and the step length is 10, then the new weight of element 1 is 60+10=70, and then the weight of element 1 is updated from 10 to 70.

[0051] In another preferred embodiment, if in step S302 the position identifiers are set in order from large to small weights (i.e., the position identifier with large weights is small, and the position identifier with small weights is large), then the new weight of the target element in this step can be half of the weight of the element corresponding to the last position identifier.

[0052] Step S311: Obtain the weight of the element corresponding to the current position identifier and the weight of the element corresponding to the position identifier after the current position identifier, and use half of the sum of the two weights as the new weight of the target element to update the weight of the target element, and execute step S312. In a preferred embodiment, assuming that element 1 needs to be moved to the 4th regional position, the original element of the 4th regional position is element 4, whose weight is 40, and the element of the 5th position is element 5, whose weight is 50, then the new weight of element 1 is (40+50) / 2=45, and then the weight of element 1 is updated from 10 to 45.

[0053] Step S312: Sort all elements of the user interface according to the updated weights. In a preferred embodiment, after element 6 is moved from the last area position to the third area position, its new weight is 25, and all elements of the current user interface are still sorted in order of weight from small to large, and the dragged element 6 is located between element 2 and element 3.

[0054] Figure 6 Schematic diagram of the sorting result of the element sorting method according to an embodiment of the present invention. Figure 6 As shown, after element 6 is moved from the last area position to the third area position, the new element order is element 1, element 2, element 6, element 3, element 4 and element 5.

[0055] The above embodiment describes the dragging and sorting of an element. In a preferred embodiment, the user can drag multiple elements at the same time, such as dragging element 5 and element 6 at the same time to place them in the second and third area positions respectively, and the element sorting can be achieved by performing the above process multiple times.

[0056] It can be seen from the element sorting method of the embodiment of the present invention that by setting weights and position identifiers for the elements of the user interface in advance, when the user stops dragging the target element, the weight of the target element is updated according to the weights of the elements corresponding to the current position identifier and its adjacent position identifiers, so that the present application only needs to update the weight of the target element to achieve element sorting, which is efficient and fast and does not require moving the positions of other elements affected by the sorting; by setting weights and position identifiers for the elements in advance, it is convenient to update the weight of the target element later to re-sort the elements of the user interface; after the dragging operation, half of the sum of the weights of the two elements before and after the target element is located in the area is used as the new weight, thereby ensuring the balance of the data interval.

[0057] Figure 7 Schematic diagram of the main modules of the element sorting device according to an embodiment of the present invention. Figure 7 As shown, the element sorting device 700 of the embodiment of the present invention mainly includes:

[0058] The acquisition module 701 is used to acquire the current position identifier of the target element when it is detected that the dragging operation on the target element of the user interface stops; wherein each element of the user interface is set with a weight and a position identifier set according to the weight. The user drags an element of the user interface, and the element may be, for example, a desktop icon of the client, an item in a display list, etc. A position identifier is set in advance for each element of the user interface to uniquely identify the current order of each element. If the client detects that the user stops dragging the target element, the position identifier of the original element corresponding to the current location of the target element is acquired, and the position identifier is used as the current position identifier of the target element.

[0059] Update module 702 is used to update the weight of the target element according to the weight of the element corresponding to the current position identifier and the weight of the element corresponding to its adjacent position identifier. A unique weight is set in advance for each element of the user interface, and all elements are sorted according to the weight. The result of the weight sorting is the current order of each element. If the current position identifier of the target element is smaller than its position identifier, it means that the target element needs to be sorted in front of its original position; if the current position identifier of the target element is larger than its position identifier, it means that the target element needs to be sorted behind its original position; half of the sum of the weights of the two elements before and after the target element after dragging is used as the new weight of the target element.

[0060] The sorting module 703 is used to sort all elements of the user interface according to the updated weights. This module has the same rules as the updating module 702 for sorting all elements according to weights, that is, they are sorted in order from small to large or from large to small. The function of dragging and sorting the elements of the user interface can be realized through the above module.

[0061] In addition, the element sorting device 700 of the embodiment of the present invention may also include: a setting module and a judgment update module ( Figure 7(not shown). Among them, the setting module is used to set a unique weight for each element of the user interface, sort all elements according to the size of the weight; and set the position identifier for each element according to the weight sorting result. The judgment and update module is used to judge whether the current position identifier is the first position identifier or the last position identifier; if the current position identifier is the first position identifier, the weight of the element corresponding to the first position identifier is obtained, and half of the obtained weight is used as the new weight of the target element to update the weight of the target element; and if the current position identifier is the last position identifier, the weight of the element corresponding to the last position identifier is obtained, and the sum of the obtained weight and the preset step size is used as the new weight of the target element to update the weight of the target element.

[0062] From the above description, it can be seen that by setting weights and position identifiers for the elements of the user interface in advance, when the user stops dragging the target element, the weight of the target element is updated according to the weights of the elements corresponding to the current position identifier and its adjacent position identifiers, so that the present application only needs to update the weight of the target element to achieve element sorting, which is efficient and fast and does not require moving the positions of other elements affected by the sorting; by setting weights and position identifiers for the elements in advance, it is convenient to update the weight of the target element later to re-sort the elements of the user interface; after the drag operation, half of the sum of the weights of the two elements before and after the target element is located in the area is used as the new weight, thereby ensuring the balance of the data interval.

[0063] Figure 8 An exemplary system architecture 800 is shown to which the element sorting method or element sorting device according to the embodiment of the present invention can be applied.

[0064] like Figure 8 As shown, system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. Network 804 is used to provide a medium for communication links between terminal devices 801, 802, 803 and server 805. Network 804 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0065] Users can use terminal devices 801, 802, and 803 to interact with server 805 through network 804 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 801, 802, and 803, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).

[0066] The terminal devices 801 , 802 , and 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0067] The server 805 may be a server that provides various services, such as a background management server (only an example) that provides support for click events generated by users using the terminal devices 801, 802, and 803. The background management server may analyze and process the received click data, text content, and other data, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.

[0068] It should be noted that the element sorting method provided in the embodiment of the present application is generally executed by the terminal devices 801 , 802 , and 803 , and accordingly, the element sorting device is generally arranged in the terminal devices 801 , 802 , and 803 .

[0069] It should be understood that Figure 8 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0070] According to an embodiment of the present invention, the present invention also provides an electronic device and a computer-readable medium.

[0071] The electronic device of the present invention comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the element sorting method of the embodiment of the present invention.

[0072] The computer-readable medium of the present invention stores a computer program thereon, and when the program is executed by a processor, the element sorting method of the embodiment of the present invention is implemented.

[0073] Reference below Fig. 9 , which shows a schematic diagram of the structure of a computer system 900 suitable for implementing an electronic device of an embodiment of the present invention. Fig. 9 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0074] like Fig. 9As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the system 900 are also stored. The CPU 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0075] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.

[0076] In particular, according to the embodiments disclosed in the present invention, the process described in the main step diagram above can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the central processing unit (CPU) 901, the above-mentioned functions defined in the system of the present invention are executed.

[0077] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0078] The main step diagrams and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of boxes in the block diagram or flow chart, can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0079] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes an acquisition module, an update module, and a sorting module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the acquisition module may also be described as "a module for acquiring the current position identifier of the target element of the user interface when it is detected that the dragging operation on the target element of the user interface is stopped."

[0080] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: when it is detected that the dragging operation on the target element of the user interface stops, the current position identifier of the target element is obtained; wherein each element of the user interface is provided with a weight and a position identifier set according to the weight; according to the weight of the element corresponding to the current position identifier and the weight of the element corresponding to its adjacent position identifier, the weight of the target element is updated; and all elements of the user interface are sorted according to the updated weight.

[0081] From the above description, it can be seen that by setting weights and position identifiers for the elements of the user interface in advance, when the user stops dragging the target element, the weight of the target element is updated according to the weights of the elements corresponding to the current position identifier and its adjacent position identifiers, so that the present application only needs to update the weight of the target element to achieve element sorting, which is efficient and fast and does not require moving the positions of other elements affected by the sorting; by setting weights and position identifiers for the elements in advance, it is convenient to update the weight of the target element later to re-sort the elements of the user interface; after the drag operation, half of the sum of the weights of the two elements before and after the target element is located in the area is used as the new weight, thereby ensuring the balance of the data interval.

[0082] The above product can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the method provided by the embodiment of the present invention.

[0083] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for sorting elements, characterized in that: include: When it is detected that the dragging operation on the target element of the user interface is stopped, the regional position of the target element when the dragging operation is stopped is obtained, and the position identifier of the original element at the regional position is used as the current position identifier of the target element; wherein each element of the user interface is set with a weight and a position identifier set according to the weight; The weight of the target element is updated according to the weight of the element corresponding to the current position identifier and the weight of the element corresponding to its adjacent position identifier, including: if the current position identifier is smaller than the position identifier and is not the first position identifier, then the weight of the element corresponding to the current position identifier and the weight of the element corresponding to the position identifier before the current position identifier are obtained; if the current position identifier is larger than the position identifier and is not the last position identifier, then the weight of the element corresponding to the current position identifier and the weight of the element corresponding to the position identifier after the current position identifier are obtained; half of the sum of the two obtained weights is used as the new weight of the target element to update the weight of the target element; Determine whether the current position identifier is the first position identifier or the last position identifier; if the current position identifier is the first position identifier, obtain the weight of the element corresponding to the first position identifier, and use half of the obtained weight as the new weight of the target element to update the weight of the target element; if the current position identifier is the last position identifier, obtain the weight of the element corresponding to the last position identifier, and use the sum of the obtained weight and a preset step size as the new weight of the target element to update the weight of the target element; All elements of the user interface are sorted according to the updated weights.

2. The method according to claim 1, characterized in that: Before the step of obtaining the current position identifier of the target element, the method further includes: Setting a unique weight for each element of the user interface, and sorting all elements according to the weights; The position identifier is set for each element according to the weight sorting result.

3. An element sorting device, characterized in that: include: An acquisition module, for, when detecting that the dragging operation on the target element of the user interface is stopped, acquiring the regional position of the target element when the dragging operation is stopped, and using the position identifier of the original element at the regional position as the current position identifier of the target element; wherein each element of the user interface is provided with a weight and a position identifier set according to the weight; An updating module, used for updating the weight of the target element according to the weight of the element corresponding to the current position identifier and the weight of the element corresponding to its adjacent position identifier, including: if the current position identifier is smaller than the position identifier and is not the first position identifier, obtaining the weight of the element corresponding to the current position identifier and the weight of the element corresponding to the position identifier before the current position identifier; if the current position identifier is larger than the position identifier and is not the last position identifier, obtaining the weight of the element corresponding to the current position identifier and the weight of the element corresponding to the position identifier after the current position identifier; using half of the sum of the two obtained weights as the new weight of the target element to update the weight of the target element; Determine whether the current position identifier is the first position identifier or the last position identifier; if the current position identifier is the first position identifier, obtain the weight of the element corresponding to the first position identifier, and use half of the obtained weight as the new weight of the target element to update the weight of the target element; if the current position identifier is the last position identifier, obtain the weight of the element corresponding to the last position identifier, and use the sum of the obtained weight and a preset step size as the new weight of the target element to update the weight of the target element; The sorting module is used to sort all elements of the user interface according to the updated weights.

4. The device according to claim 3, characterized in that The device further includes: a setting module, configured to set a unique weight for each element of the user interface, and sort all elements according to the weight; and The position identifier is set for each element according to the weight sorting result.

5. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-2.

6. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 2 is implemented.

Citation Information

Patent Citations

  • Sequence optimization method of custom element based on LCS (Longest Common Subsequence)

    CN105956064A

  • Notification area that persistently rearranges elements

    US20090327940A1