{"id":42014,"date":"2016-01-16T11:23:00","date_gmt":"2016-01-16T11:23:00","guid":{"rendered":"http:\/\/ahay.org\/blog\/?p=42014"},"modified":"2016-02-16T23:24:56","modified_gmt":"2016-02-16T23:24:56","slug":"program-of-the-month-sfsort","status":"publish","type":"post","link":"https:\/\/ahay.org\/blog\/2016\/01\/16\/program-of-the-month-sfsort\/","title":{"rendered":"Program of the month: sfsort"},"content":{"rendered":"<p><a href=\"\/RSF\/sfsort.html\">sfsort<\/a> sorts the input by absolute value.<\/p>\n<p>It takes either floating-point or complex input. Here is a quick example:<\/p>\n<div class=\"code-box\"><div class=\"code-title\"><i class=\"fa fa-code\"><\/i> <div class=\"pull-right\"><a href=\"#\" class=\"btn btn-default btn-xs toggle-code\" data-toggle=\"tooltip\" title=\"Toggle code\"><i class=\"fa fa-toggle-up\"><\/i><\/a><\/div><\/div><pre >\nbash$ sfspike n1=10 | sfnoise rep=y seed=2016 > random.rsf\nbash$ < random.rsf sfdisfil\n   0:       -0.3485      -0.3108       0.7928      0.01292      -0.5301\n   5:       -0.4556      -0.2901      -0.7167       -1.209      -0.2871\nbash$  < random.rsf sfsort | sfdisfil\n   0:         1.209       0.7928       0.7167       0.5301       0.4556\n   5:        0.3485       0.3108       0.2901       0.2871      0.01292\n<\/pre><\/div>\n<p>To sort in reverse (ascending) order, use <strong>ascmode=y<\/strong>:<\/p>\n<div class=\"code-box\"><div class=\"code-title\"><i class=\"fa fa-code\"><\/i> <div class=\"pull-right\"><a href=\"#\" class=\"btn btn-default btn-xs toggle-code\" data-toggle=\"tooltip\" title=\"Toggle code\"><i class=\"fa fa-toggle-up\"><\/i><\/a><\/div><\/div><pre > \nbash$ < random.rsf sfsort ascmode=y | sfdisfil\n   0:       0.01292       0.2871       0.2901       0.3108       0.3485\n   5:        0.4556       0.5301       0.7167       0.7928        1.209\n<\/pre><\/div>\n<p><strong>sfsort<\/strong> tries to perform sorting in memory but, if the input is too large, it switches to slower out-of-core operations. To control the amount of available memory, use <strong>memsize=<\/strong> parameter.<\/p>\n<p>If the input is multidimensional, and you want to sort data only up to a certain dimension, use <strong>dim=<\/strong> parameter. In the following example, each of the two rows is sorted independently:<\/p>\n<div class=\"code-box\"><div class=\"code-title\"><i class=\"fa fa-code\"><\/i> <div class=\"pull-right\"><a href=\"#\" class=\"btn btn-default btn-xs toggle-code\" data-toggle=\"tooltip\" title=\"Toggle code\"><i class=\"fa fa-toggle-up\"><\/i><\/a><\/div><\/div><pre >\nbash$ < random.rsf sfput n1=5 n2=2 | sfsort dim=1 | sfdisfil\n   0:        0.7928       0.5301       0.3485       0.3108      0.01292\n   5:         1.209       0.7167       0.4556       0.2901       0.2871\n<\/pre><\/div>\n<p><strong>sfsort<\/strong> was contributed to Madagascar by Gilles Hennenfent and Henryk Modzelewski from <a href=\"https:\/\/www.slim.eos.ubc.ca\/\">SLIM<\/a>, UBC. They provide the <a href=\"\/RSF\/book\/slim\/slimUserManual\/paper_html\/node6.html\">following test example<\/a> in <a href=\"\/RSF\/book\/slim\/slimUserManual\/sfsort.html\">slim\/slimUserManual\/sfsort<\/a>:<\/p>\n<p><img decoding=\"async\" src=\"\/RSF\/book\/slim\/slimUserManual\/sfsort\/Fig\/datasort.png\" alt=\"\" title=\"\" \/> <img decoding=\"async\" src=\"\/RSF\/book\/slim\/slimUserManual\/sfsort\/Fig\/incore.png\" alt=\"\" title=\"\" \/> <img decoding=\"async\" src=\"\/RSF\/book\/slim\/slimUserManual\/sfsort\/Fig\/outofcore.png\" alt=\"\" title=\"\" \/><\/p>\n<h3 id=\"10previousprogramsofthemonth\">10 previous programs of the month:<\/h3>\n<ul>\n<li><a href=\"\/blog\/2015\/12\/22\/program-of-the-month-sfdivn\/\">sfdivn<\/a><\/li>\n<li><a href=\"\/blog\/2015\/11\/16\/program-of-the-month-sfpldb-and-sfplas\/\">sfpldb and sfplas<\/a><\/li>\n<li><a href=\"\/blog\/2015\/10\/15\/program-of-the-month-sfisolr2\/\">sfisolr2<\/a><\/li>\n<li><a href=\"\/blog\/2015\/09\/14\/program-of-the-month-sfsimilarity\/\">sfsimilarity<\/a><\/li>\n<li><a href=\"\/blog\/2015\/07\/10\/program-of-the-month-sfmutter\/\">sfmutter<\/a><\/li>\n<li><a href=\"\/blog\/2015\/06\/10\/program-of-the-month-sfintbin\/\">sfintbin<\/a><\/li>\n<li><a href=\"\/blog\/2015\/05\/01\/program-of-the-month-sfbox\/\">sfbox<\/a><\/li>\n<li><a href=\"\/blog\/2015\/04\/21\/program-of-the-month-sfslant\/\">sfslant<\/a><\/li>\n<li><a href=\"\/blog\/2015\/03\/04\/program-of-the-month-sfgrey\/\">sfgrey<\/a><\/li>\n<li><a href=\"\/blog\/2015\/03\/01\/program-of-the-month-sfhistogram\/\">sfhistogram<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>sfsort sorts the input by absolute value. It takes either floating-point or complex input. Here is a quick example: bash$ sfspike n1=10 | sfnoise rep=y seed=2016 > random.rsf bash$ < random.rsf sfdisfil 0: -0.3485 -0.3108 0.7928 0.01292 -0.5301 5: -0.4556 -0.2901 -0.7167 -1.209 -0.2871 bash$ < random.rsf sfsort | sfdisfil 0: 1.209 0.7928 0.7167 0.5301 [&hellip;]\n<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[3],"tags":[],"class_list":["post-42014","post","type-post","status-publish","format-standard","hentry","category-programs"],"_links":{"self":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts\/42014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/comments?post=42014"}],"version-history":[{"count":3,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts\/42014\/revisions"}],"predecessor-version":[{"id":47825,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts\/42014\/revisions\/47825"}],"wp:attachment":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/media?parent=42014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/categories?post=42014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/tags?post=42014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}