{"id":7377,"date":"2016-04-23T21:41:59","date_gmt":"2016-04-23T12:41:59","guid":{"rendered":"http:\/\/www.gesource.jp\/weblog\/?p=7377"},"modified":"2017-09-30T09:30:43","modified_gmt":"2017-09-30T00:30:43","slug":"tstringlist%e3%81%ae%e8%a6%81%e7%b4%a0%e3%82%92%e6%96%87%e5%ad%97%e5%88%97%e3%81%ae%e9%95%b7%e3%81%95%e3%81%a7%e3%82%bd%e3%83%bc%e3%83%88%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.gesource.jp\/weblog\/?p=7377","title":{"rendered":"TStringList\u306e\u8981\u7d20\u3092\u6587\u5b57\u5217\u306e\u9577\u3055\u3067\u30bd\u30fc\u30c8\u3059\u308b"},"content":{"rendered":"<p>Delphi\u306eTStringList\u306b\u306f\u3001\u30ea\u30b9\u30c8\u5185\u306e\u6587\u5b57\u5217\u3092\u6607\u9806\u3067\u30bd\u30fc\u30c8\u3059\u308b<a href=\"http:\/\/docwiki.embarcadero.com\/Libraries\/Berlin\/ja\/System.Classes.TStringList.Sort\">Sort<\/a>\u30e1\u30bd\u30c3\u30c9\u306e\u4ed6\u306b\u3001\u4efb\u610f\u306e\u6761\u4ef6\u3067\u30bd\u30fc\u30c8\u3059\u308b<a href=\"http:\/\/docwiki.embarcadero.com\/Libraries\/Berlin\/ja\/System.Classes.TStringList.CustomSort\">CustomSort<\/a>\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\nTStringList\u306e<a href=\"http:\/\/docwiki.embarcadero.com\/Libraries\/Berlin\/ja\/System.Classes.TStringList.CustomSort\">CustomSort<\/a>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u3001\u6587\u5b57\u5217\u306e\u9577\u3055\u3067\u30bd\u30fc\u30c8\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/docwiki.embarcadero.com\/Libraries\/Berlin\/ja\/System.Classes.TStringList.CustomSort\">CustomSort<\/a>\u30e1\u30bd\u30c3\u30c9\u306f\u5f15\u6570\u306bTStringListSortCompare\u578b\u306e\u95a2\u6570\u3092\u3068\u308a\u307e\u3059\u3002<br \/>\nTStringListSortCompare\u578b\u306f\u6b21\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><code>TStringListSortCompare = function(List: TStringList; Index1, Index2: Integer): Integer;\n<\/code><\/pre>\n<p>TStringListSortCompare\u578b\u306e\u6587\u5b57\u5217\u306e\u9577\u3055\u3092\u6bd4\u8f03\u3059\u308b\u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre><code>function StringLengthCompare(List: TStringList; Index1, Index2: Integer): Integer;\nbegin\n  Result := List[Index1].Length - List[Index2].Length;\nend;\n<\/code><\/pre>\n<p>TStringList\u306eCustomSort\u30e1\u30bd\u30c3\u30c9\u306e\u5f15\u6570\u306b\u3053\u306e\u95a2\u6570\u3092\u6e21\u3059\u3068\u3001\u6587\u5b57\u5217\u306e\u9577\u3055\u9806\u306b\u30bd\u30fc\u30c8\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306e\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068TStringList\u306e\u6587\u5b57\u5217\u3092\u30bd\u30fc\u30c8\u3057\u3066\u7d50\u679c\u3092\u30e1\u30e2\u306b\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a9\u30fc\u30e0\u306bTButton\u3068TMemo\u3092\u914d\u7f6e\u3057\u307e\u3059\u3002<br \/>\n\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001\u30bd\u30fc\u30c8\u7d50\u679c\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<pre><code>function StringLengthCompare(List: TStringList; Index1, Index2: Integer): Integer;\nbegin\n  Result := List[Index1].Length - List[Index2].Length;\nend;\n\nprocedure TForm1.Button1Click(Sender: TObject);\nvar\n  stli: TStringList;\nbegin\n  stli := TStringList.Create;\n\n  \/\/ \u304a\u8a66\u3057\u30c7\u30fc\u30bf\u683c\u7d0d\n  stli.Add('aa');\n  stli.Add('a');\n  stli.Add('aaaaa');\n  stli.Add('aaaa');\n  stli.Add('aaa');\n\n  stli.CustomSort(StringLengthCompare);\n  Memo1.Text := stli.Text;\n\n  stli.Free;\nend;\n<\/code><\/pre>\n<p><a href=\"\/weblog\/wp-content\/uploads\/2016\/04\/sort01.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/weblog\/wp-content\/uploads\/2016\/04\/sort01.png\" alt=\"sort01\" width=\"222\" height=\"189\" class=\"alignnone size-full wp-image-7378\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Delphi\u306eTStringList\u306b\u306f\u3001\u30ea\u30b9\u30c8\u5185\u306e\u6587\u5b57\u5217\u3092\u6607\u9806\u3067\u30bd\u30fc\u30c8\u3059\u308bSort\u30e1\u30bd\u30c3\u30c9\u306e\u4ed6\u306b\u3001\u4efb\u610f\u306e\u6761\u4ef6\u3067\u30bd\u30fc\u30c8\u3059\u308bCustomSort\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308a\u307e\u3059\u3002 TStringList\u306eCustomSort\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f &#8230;<\/p>\n<p><a href=\"https:\/\/www.gesource.jp\/weblog\/?p=7377\" class=\"more-link\">Continue reading &lsquo;TStringList\u306e\u8981\u7d20\u3092\u6587\u5b57\u5217\u306e\u9577\u3055\u3067\u30bd\u30fc\u30c8\u3059\u308b&rsquo; &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[48],"tags":[156,118,44],"class_list":["post-7377","post","type-post","status-publish","format-standard","hentry","category-delphi","tag-delphi","tag-firemonkey","tag-vcl"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/7377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7377"}],"version-history":[{"count":0,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/7377\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}