Character string identifier sorting method and system
Through the proposed string identification sorting method, the character strings are sorted after replacement and conversion, the problem of not being able to correctly sort Chinese characters and characters with sequential meanings in the prior art is solved, and accurate and efficient sorting results are achieved.
Patent Information
- Application Number
- CN202310939219.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-28
- Publication Date
- 2025-02-14
AI Technical Summary
The prior art cannot correctly sort file names or web page list titles containing Chinese characters, Arabic numbers and characters with sequential meanings, resulting in inaccurate sorting results.
A method of sorting string identification is proposed. By obtaining the sortable content in the string to be sorted, replacing the Chinese characters with Arabic numerals, and converting characters with sequential meanings into a specific format, the common sorting algorithm is used to sort them. .
Accurate sorting of string identifiers containing Chinese characters and characters with sequential meanings is achieved, the problem of inaccurate sorting results in the prior art is solved, and the efficiency of sorting of file names and web page list titles is improved.
Smart Images

Figure CN119441379A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of string processing, and particularly relates to a method and system for sorting string identifiers. Background Art
[0002] In existing operating systems or websites, sorting algorithms for file names or various types of titles often cannot directly support correct text sorting of character identifiers containing Chinese numerals, Arabic numerals, characters with sequential meanings such as upper-middle-lower, etc. Since Chinese numerals, Arabic numerals, or characters with sequential meanings in the text cannot be recognized and sorted directly according to the encoding of letters, the results will be inaccurate. As Figure 1 、 Figure 2 shown, for some character identifiers containing Chinese numerals, according to the sorting rules of Chinese characters, "one" is sorted to the last; for some multi-digit numbers, since only the first digit is sorted, the result arranges "10" before "2".
[0003] The current sorting problem is caused by the lack of clear distinction between Chinese numerals and other characters in encoding, and the sorting algorithm cannot perform special processing on them. Summary of the Invention
[0004] The purpose of the present invention is to overcome the defect that the prior art has chaotic sorting for file names and web page list titles.
[0005] To achieve the above purpose, the present invention proposes a method for sorting string identifiers, and the method includes:
[0006] Step 1: Obtain the sortable content in the string identifier to be sorted to obtain a sortable string;
[0007] Step 2: Sort the sortable string in numerical order;
[0008] Step 3: Use the sorting result of the sortable string as the sorting result of its corresponding string identifier to be sorted.
[0009] As an improvement of the above method, the sortable content includes Chinese-form numerals, Arabic numerals, and characters containing sequence meanings.
[0010] As an improvement of the above method, Step 1 specifically includes:
[0011] Create an empty string as the initial sortable string;
[0012] Traverse the entire character identifier to be sorted, and store each character in the sortable string after a replacement operation.
[0013] As an improvement of the above method, the replacement operation specifically includes:
[0014] Replace Chinese characters with Arabic numerals;
[0015] Replace the characters that contain sequence meaning with the format of "set character + the sequence value of the character in the sequence + set character".
[0016] As an improvement to the above method, the set character is the first character of the sequence or the last character of the sequence.
[0017] As an improvement of the above method, the step 2 specifically includes:
[0018] Step 2-1: Get the length of the shortest string from all sortable strings;
[0019] Step 2-2: Use a sorting algorithm to sort all sortable strings.
[0020] As an improvement of the above method, the sorting algorithm includes a bubble sort, an insertion sort, a selection sort, a shell sort, a merge sort or a quick sort.
[0021] As an improvement to the above method, the method used when comparing two sortable strings in the sorting algorithm includes:
[0022] Using the length of the shortest string as the cycle, loop to compare two sortable strings word by word. The comparison rules are:
[0023] If both characters are numbers, use the method to obtain consecutive numbers to obtain the character and all consecutive numbers after it, and return the sort value of the two consecutive numbers;
[0024] If one of the two characters is a number and the other is a non-number, the number is sorted first;
[0025] If neither character is a digit, then the collation of the Unicode code points of the two characters is returned.
[0026] The present invention also provides a string identifier sorting system, which is implemented based on the above method, and the system comprises:
[0027] A module for obtaining a sortable string is used to obtain the sortable content in the string identifier to be sorted, and obtain a sortable string;
[0028] A sorting module, which is used to sort sortable strings into numerical order; and
[0029] The sorting result generating module is used to use the sorting result of the sortable character string as the sorting result of the corresponding character string identifier to be sorted.
[0030] Compared with the prior art, the advantages of the present invention are as follows:
[0031] 1. After applying the sorting method of the present invention, the sorting of file names or web page list identifiers conforms to people's habits of numerical sorting, improving the reading efficiency.
[0032] 2. By applying the sorting method of the present invention in the field of education, teaching content can be accurately sorted, teaching resources can be optimized and organized, the discoverability of resources can be improved, and the generation of learning outlines can be supported, overall enhancing the content organization and utilization efficiency of the education industry. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 Shows the sorting result of file names in the Apple system;
[0034] Figure 2 Shows the sorting result of the titles of the web page list;
[0035] Figure 3 Shows the flowchart of the sorting method of the string representation of the present application;
[0036] Figure 4 Shows the sorting result of the web page list sorted by the sorting method of the present application. DETAILED DESCRIPTION OF THE INVENTION
[0037] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings.
[0038] As Figure 3 shown, a sorting method and system for string identifiers of the present invention are used to sort string identifiers such as file names and lists in web pages according to their business meaning order.
[0039] Sorting according to their business meaning order includes two categories:
[0040] The first category: If the string identifier contains numbers, whether they are Chinese numbers (e.g., one, two hundred and one, etc.) or Arabic numbers (e.g., 10, 211, etc.), they are sorted according to the actual numerical order. There will be no problem as in the existing sorting where 101 appears before 2 because 1 is less than 2.
[0041] The second category: For the content of the string identifier that contains characters with sequence meaning, such as: top, middle, bottom; A, B, C, D; alpha, beta, gamma, delta; A, B, G, D; A, B, B, G; I, II, III, IV, etc., they can be sorted according to the meaning of the text content they represent, rather than according to the order of Chinese character encoding.
[0042] The specific process of the string identifier sorting method includes:
[0043] Step 1: Obtain the sortable content in the string identifier to be sorted to get a sortable string;
[0044] The sortable content includes numbers in Chinese characters, Arabic numerals, and Chinese characters with sequential meanings.
[0045] Create an empty string as the initial sortable string;
[0046] Traverse the entire string identifier to be sorted, and store each character in the sortable string after replacement;
[0047] The replacement operation includes two contents:
[0048] First: Replace the Chinese numerals with Arabic numerals; for example, replace Chinese numerals such as "one", "one", "zero" with: "1", "1", "0";
[0049] Second: Replace the characters containing sequential meanings with the form of "set character + the sequential value of the character in the sequence + set character"; for example, replace "up" with "up1up", and replace "B" with "A2A". The set character can be the first character or the last character of the sequence, or other set characters.
[0050] Step 2: Sort the sortable string in numerical order.
[0051] Step 2-1: Obtain the length of the shortest string from all sortable strings;
[0052] Step 2-2: Use a sorting algorithm to sort all sortable strings;
[0053] The sorting algorithm can be common sorting algorithms such as bubble sort, insertion sort, selection sort, shell sort, merge sort, or quick sort.
[0054] The method used to compare two sortable strings in the sorting algorithm is as follows:
[0055] Taking the length of the shortest string as the period, loop through and compare two sortable strings character by character. The comparison rule is:
[0056] If both characters are numbers, use the method of obtaining consecutive numbers to get the character and all subsequent consecutive numbers, and return the sorting value of the two consecutive numbers;
[0057] If one character is a number and the other is a non-number, sort the number first;
[0058] If neither character is a number, return the sorting value of the Unicode code values of the two characters;
[0059] Step 3: The sorting result of the sortable character string is used as the sorting result of the corresponding character string identifier to be sorted.
[0060] The list of websites sorted using the sorting method of this application is as follows Figure 4 The method of the present application realizes accurate sorting of texts containing Chinese characters, numbers, and Chinese characters with sequential meanings by supporting the recognition and conversion of Chinese characters, numbers, and Chinese characters with sequential meanings into corresponding numbers, and then intercepting continuous numbers for size comparison, thereby solving the problem that the existing sorting algorithm cannot achieve the correct sorting effect for Chinese characters, numbers, and Chinese characters with sequential meanings in file names and website lists.
[0061] The present invention also provides a string identifier sorting system, which is implemented based on the above method, and the system comprises:
[0062] A module for obtaining a sortable string is used to obtain the sortable content in the string identifier to be sorted, and obtain a sortable string;
[0063] A sorting module, which is used to sort sortable strings into numerical order; and
[0064] The sorting result generating module is used to use the sorting result of the sortable character string as the sorting result of the corresponding character string identifier to be sorted.
[0065] The present invention may also provide a computer device, comprising: at least one processor, a memory, at least one network interface and a user interface. The various components in the device are coupled together through a bus system. It is understood that the bus system is used to achieve connection and communication between these components. In addition to the data bus, the bus system also includes a power bus, a control bus and a status signal bus.
[0066] The user interface may include a display, a keyboard or a pointing device, such as a mouse, a trackball, a touch pad or a touch screen.
[0067] It is understood that the memory in the disclosed embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus random access memory (DRRAM). The memories described herein are intended to include, but are not limited to, these and any other suitable types of memories.
[0068] In some embodiments, the memory stores the following elements, executable modules or data structures, or a subset thereof, or an extended set thereof: an operating system and applications.
[0069] The operating system includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application includes various application programs, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. The program for implementing the method of the embodiment of the present disclosure can be included in the application.
[0070] In the above embodiment, the processor may also call a program or instruction stored in the memory, specifically, a program or instruction stored in an application program, and is used to:
[0071] Execute the steps of the above method.
[0072] The above method can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor may be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The above-disclosed methods, steps and logic block diagrams can be implemented or executed. The general processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the above-disclosed method can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor are combined to execute. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0073] It is understood that the embodiments described in the present invention can be implemented by hardware, software, firmware, middleware, microcode or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application or a combination thereof.
[0074] For software implementation, the technology of the present invention can be implemented by executing the functional modules (such as procedures, functions, etc.) of the present invention. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0075] The present invention may also provide a non-volatile storage medium for storing a computer program. When the computer program is executed by a processor, each step in the above method embodiment can be implemented.
[0076] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention is described in detail with reference to the embodiments, it should be understood by those skilled in the art that any modification or equivalent replacement of the technical solutions of the present invention does not depart from the spirit and scope of the technical solutions of the present invention and should be included in the scope of the claims of the present invention.
Claims
1. A method for sorting string identifiers, the method comprising: Step 1: Get the sortable content in the string identifier to be sorted, and obtain the sortable string; Step 2: Sort the sortable strings in numerical order; Step 3: The sorting result of the sortable character string is used as the sorting result of the corresponding character string identifier to be sorted.
2. The string identifier sorting method according to claim 1, characterized in that: The sortable contents include numbers in Chinese characters, Arabic numerals, and characters containing sequence meanings.
3. The string identifier sorting method according to claim 1, characterized in that: The step 1 specifically includes: Create an empty string as the initial sortable string; Traverse the entire set of character identifiers to be sorted, replace each character, and store them in a sortable string.
4. The string identifier sorting method according to claim 3, characterized in that: The replacement operation specifically includes: Replace Chinese characters with Arabic numerals; Replace the characters that contain sequence meaning with the format of "set character + the sequence value of the character in the sequence + set character".
5. The string identifier sorting method according to claim 4, characterized in that: The set character is the first character of the sequence or the last character of the sequence.
6. The string identifier sorting method according to claim 1, characterized in that: The step 2 specifically includes: Step 2-1: Get the length of the shortest string from all sortable strings; Step 2-2: Use a sorting algorithm to sort all sortable strings.
7. The string identifier sorting method according to claim 6, characterized in that: The sorting algorithms include bubble sort, insertion sort, selection sort, shell sort, merge sort or quick sort.
8. The string identifier sorting method according to claim 6, characterized in that: The methods used to compare two sortable strings in the sorting algorithm include: Using the length of the shortest string as the cycle, loop to compare two sortable strings word by word. The comparison rules are: If both characters are numbers, use the method to obtain consecutive numbers to obtain the character and all consecutive numbers after it, and return the sort value of the two consecutive numbers; If one of the two characters is a number and the other is a non-number, the number is sorted first; If neither character is a digit, then the collation of the Unicode code points of the two characters is returned.
9. A string identifier sorting system, implemented based on any of the methods described in claims 1-8, characterized in that: The system comprises: A module for obtaining a sortable string is used to obtain the sortable content in the string identifier to be sorted, and obtain a sortable string; A sorting module, which is used to sort sortable strings into numerical order; and The sorting result generating module is used to use the sorting result of the sortable character string as the sorting result of the corresponding character string identifier to be sorted.
Citation Information
Cited By
Database data processing method and device based on multi-rule dynamic sorting
CN120470157A