{"id":9342,"date":"2020-12-12T15:45:47","date_gmt":"2020-12-12T20:45:47","guid":{"rendered":"https:\/\/irreal.org\/blog\/?p=9342"},"modified":"2020-12-12T15:45:47","modified_gmt":"2020-12-12T20:45:47","slug":"sorting-with-regular-expressions","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=9342","title":{"rendered":"Sorting with Regular Expressions"},"content":{"rendered":"<p>Tory Anderson has a nice <a href=\"https:\/\/tech.toryanderson.com\/2020\/12\/12\/emacs-sorting-with-sort-regexp-fields\/\">use case for the sort-regexp-fields command<\/a>. When I first saw his post I thought <code>sort-regexp-fields<\/code> was another new find for me. But on checking, I discovered that I had used in back in 2011 in an <a href=\"https:\/\/irreal.org\/blog\/?p=330\">attempted solution to one of Xah Lee\u2019s EmacsGolf challenges<\/a>. Lee\u2019s post has since disappeared but you can see the problem at the above link. Apparently <code>sort-regexp-fields<\/code> is one of those commands that I don\u2019t use very often and tend to forget.<\/p>\n<p>That\u2019s too bad because, as Anderson shows, it can be very useful. It\u2019s not even hard to use. You just need to remember that it exists. The basic idea is that you give the command two regular expressions. The first specifies the record\u2014a line or paragraph, say\u2014and the second matches the key in the record. Then the command sorts the records lexigraphically based on the key. That\u2019s all there is to it. Simple but powerful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tory Anderson has a nice use case for the sort-regexp-fields command. When I first saw his post I thought sort-regexp-fields was another new find for me. But on checking, I discovered that I had used in back in 2011 in &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=9342\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18],"class_list":["post-9342","post","type-post","status-publish","format-standard","hentry","category-general","tag-emacs"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/9342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9342"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/9342\/revisions"}],"predecessor-version":[{"id":9343,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/9342\/revisions\/9343"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}