Sort the numbers in series by tstringlist-reply to the lancerning issue

Source: Internet
Author: User
Problem Source: http://www.cnblogs.com/del/archive/2008/04/07/1134178.html#1141173
Unit unit1; interfaceuses windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; Procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} {write a function in descending order of numbers} function desccompareint (list: tstringlist; I1, I2: integer): integer; begin I1: = strtointdef (list [I1], 0); I2: = strtointdef (list [I2], 0); Result: = I2-I1; end; Procedure tform1.button1click (Sender: tobject); var list: tstringlist; begin list: = tstringlist. create; List. commatext: = '5, '; List. customsort (desccompareint); {the function called during sorting} showmessage (list. text); {87 65 21 5 4 3 1} List. free; end.

 

In addition, you can use the names and valuefromindex attributes of tstringlist to Solve the Problem corresponding to other data, or use the case statement for extraction.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.