Questions tagged [sorting]

Use the sorting tag for questions involving arranging things in a defined order: sorting lines alphabetically, bibtex entries by date or author, emails by sender, completion candidates by various criteria, etc.

Filter by
Sorted by
Tagged with
2
votes
1answer
50 views

Custom agenda sorting by CREATED date

I put together the function below but it doesn't work. The problem is get-text-property returns nil for every task. Any idea how to get the CREATED property and fix the entire thing? (defun jarfar/org-...
0
votes
1answer
36 views

How to efficiently merge 2 buffers which are partially overlapping?

Problem summary Imagine, you have 2 shopping lists: 1 huge one with hundreds of entries - list A, copied into buffer A 1 containing dozens of entries - list B, copied into buffer B Then: 75% of ...
3
votes
1answer
99 views

Sort Chinese Characters in Emacs

Is there a ready-made function that sorts Chinese characters (by pinyin or stroke number) in Emacs in an org-table or line by line in regular text? If not, how should one go about writing such ...
1
vote
1answer
103 views

How to sort in Dired by size and extension and have directories listed first and full date/time details

I'm using the excelent dired-fixups.el by Dino Chiesa for sorting in Dired by size and extension (see here). The only gotcha is that I'd like to combine it with a fuller date/time description. Also, ...
0
votes
0answers
34 views

Avoid reordering of buffer list when switching buffer

I'm trying to make emacs buffer list to behave like tabs in most web browsers: If I open buffers "1", "2" and "3" in that order, they should remain in that order unles I move them on purpose with ...
2
votes
1answer
26 views

Is there a way to change order of the key in a hashtable?

Say i have following keys in hashtable: "first1" "second2" "third3" "forth4" Is there a way to put key "third3" at the top. So that when i run func hash-table-keys i get following list: ("third3" "...
5
votes
0answers
116 views

Sort ripgrep results based on proximity to current buffer

I use counsel-projectile-rg to search within the project I work on. But there is my sub-project inside this big repo that most of my development is in. Is there a way to sort ripgrep results based on ...
1
vote
1answer
58 views

How to sort comma separated (or otherwise) text?

Suppose I have the following text: int z; int a; int c; int g; or the following text: z, a, c, g How can I sort them to: int a; int c; int g; int z; and a, c, g, z respectively?
1
vote
1answer
396 views

Ivy: sort candidates by most recently used

I'm coming from Helm to Ivy just to try it out, and one thing I miss greatly from Helm is how the default candidate when hitting M-x is whatever the last command was. Is there some way to sort Ivy's ...
0
votes
0answers
14 views

Correct alphabetizing/sorting order with string-collate-lessp?

Q: how can I get string-collate-lessp to sort correctly? string-collate-lessp is supposed to sort two strings in collation order: Return t if first arg string is less than second in collation ...
1
vote
2answers
103 views

How to order a single line relative to other lines in a block of text?

How can a line be sorted relative to other lines at the same indentation level? This would be useful whenever adding an item to an ordered list of definitions (file lists or forward definitions). ...
1
vote
0answers
38 views

Sorting org files in Emacs Dired on the basis of the org time stamp in the file itself

Is there a way of sorting org files (.org) in Emacs Dired on the basis of the org time stamp in the file itself. With every org file I create, I insert an org time stamp near the top of the file. This ...
1
vote
1answer
23 views

Why dired+ not save sort mode?

windows 10, Emacs 26.1, Dired+ Suppose I has 3 files and sort it by name in dired mode. Smt like this: OK. Now I sort it by date, press s Here result: OK. Now I edit file 3.txt and after save ...
0
votes
0answers
119 views

how to sort tasks in agenda using todo-state-up?

I defined 4 TODO keywords. Two are in the TODO state and two others (DONE and CNCL) belong to the DONE state: (setq org-todo-keywords '((sequence "TODO" "WAIT" "|" "DONE" "CNCL" ))) I defined ...
0
votes
1answer
31 views

emacs ruby mode: can I reorder methods in file (alphabetical order)

After opening the file app/controllers/pages_controller.rb Which has class PagesController < ApplicationController def foo puts "foo" end def baa puts "baa" end end I ...
2
votes
1answer
69 views

is there a way to sort only on second level headlines in org mode?

is there a way to sort only on second level headlines in org mode? i am outlining a novel with top level headline being the chapter number and the second level headline being the timeline of the ...
1
vote
1answer
168 views

Why so strange sort in dired mode?

windows 10, emacs 26.1, dired+ here myfolder in dired mode sort by name (by default): Now I want to sort by date (inverse mode). I press s and here result: why file new.txt is above two dots? The ...
2
votes
1answer
99 views

Is there a timsort implementation in Emacs Lisp?

Timsort is the default sort algo of Python and Java and it performs better than mergesort on roughly sorted lists. I could not find any implementation of this in Elisp. How can I find out whether ...
2
votes
1answer
64 views

Getting a sorted window list

(window-list) returns a list of visible windows. Is it possible to get this list sorted from the most recently active window to the least?
1
vote
1answer
50 views

sort-columns, but with a stable sort

How can I perform the equivalent of M-x sort-columns with a stable sort? For example, let's say my text is: a 99 b 98 b 97 a 96 a 95 b 94 a 93 b 92 c 91 ... And I want to perform a stable sort ...
7
votes
1answer
164 views

How to alphabetize strings with diacritics?

Q: how do I alphabetize strings with diacritics? Problem I have a long list of author names, some of whom have letters with diacritics in their names (e.g., "á" or "é"). I want to sort this list ...
2
votes
1answer
65 views

Implementing (org-agenda) sort comparison function in terms of presence of list items

I want to implement an org-agenda-cmp-user-defined for use with org-agenda-sorting-strategy and user-defined-up / user-defined-down. In order to do that, I have two lists of tags I need to compare, ...
1
vote
1answer
152 views

Finding next and previous entries in an avl-tree

I am using an avl-tree to maintain a sorted list, e.g.: (require 'avl-tree) (let ((tree (avl-tree-create (lambda (a b) (string-lessp (car a) (car b)))))) (avl-tree-enter tree (cons "b" 0)) (avl-...
1
vote
1answer
70 views

Reorder fields using bibtex-mode

I would like to clean up BibTeX entries so that fields always appear in the same order. For example, I would like the order of fields to always be: author, year, title, journal. So, pressing C-c C-q ...
3
votes
1answer
108 views

Sort org-agenda items by category

When using the agenda in org-mode to show my daily tasks, there's a bunch of tasks scheduled for that day (or with past deadlines) that appear at the bottom. I'd like these tasks, and only these, to ...
0
votes
2answers
57 views

How to sort lines ignoring a pattern?

I would like to sort some lines, ignoring a leading part of them. Here's an example from my .spacemacs file: '( better-defaults elixir emacs-lisp erlang evil-commentary ...
2
votes
1answer
196 views

How does sorting work within habits?

I think I have a reasonable handle on agenda custom sorting, but I can't figure out how habits sort themselves within that agendas. For a certain agenda view I sort as '(time-up habit-down todo-state-...
0
votes
1answer
91 views

How to convert paragraph into the line?

I've need a function which convert a paragraph into the line, sort each space separated set of characters and fill it back to paragraph. In: Supposedly there are over one million words in the ...
1
vote
1answer
112 views

Sort entire hirearchy in an Org mode buffer

Running Emacs 25.2.2. Consider the following heading hierarchy: * L1 ** C *** 2 *** 1 ** B *** 3 *** 2 I want to sort it to: * L1 ** B *** 1 *** 2 ** C *** 2 ...
0
votes
1answer
70 views

Sort js object by name

I'd like to sort objects by prop name, eg const a = { method: "GET", url: "asd", headers: { Content: "application/json", Authorization: "token", }, } then select only ...
0
votes
1answer
49 views

How to NOT sort icicles menu output?

Using an icicles menu with emacs 26.1, I'm now having the menu sorted. The menu used to be unsorted (items appeared in the order they were given). In the previous version of emacs they were unsorted. ...
0
votes
1answer
89 views

How to sort a list of files/directories by hierarchical depth?

I am working on implementing my own feature request -- http://debbugs.gnu.org/cgi/bugreport.cgi?bug=31601 -- to give wdired the ability to handle a dired- buffer that contains an arbitrary list of ...
1
vote
0answers
46 views

Sort CSS declarations alphanumerically

As per the Google style guide (but this is a generally recognized as good practice) the CSS declarations should be sorted within rules blocks. So given the following code: .ruleOne { width: 40px; ...
2
votes
2answers
370 views

Sort list by decreasing length of the strings

I have this list: (setq MYLIST '("J. Phys." "New. J. Phys." "J. Phys. Soc. Jap." "Phys. Plasmas")) How can I get a new list ordered by the decreasing ...
4
votes
2answers
146 views

How to sort bash functions alphabetically?

My boss is a bit of a neat freak. He wants the functions in my functions.sh be ordered alphabetically. foo() { echo foo } baa() { echo baa } So baa should appear first in the file. Can emacs ...
0
votes
1answer
368 views

Open emacs in Dired mode

I would like to open emacs in dired mode . files and folders should be organised in most recent file first order. Moreover I would like to highlight the Org files for easy selection. Is this possible?
5
votes
2answers
371 views

Find files with find-dired sorting by date and by size

I often use find-dired and find-named-dired. But I wanted to get the results sorted by date and by size. How can I do that?
2
votes
1answer
615 views

How to sort an association list (alist)?

Is there a way to sort an association list? In my case I would like to sort the alist elements by the values in each list element (represented by the integers in the example below). Example: (setq ...
3
votes
1answer
73 views

How is it possible to sort todos by completion?

How is it possible to sort todos by completion? * Bar [0%] ** TODO Bar1 ** TODO Bar2 * Foo [100%] ** DONE Foo1 CLOSED: [2017-06-18 So 17:51] ** DONE Foo2 CLOSED: [2017-06-18 So 17:51] * Foo1 [0%]...
1
vote
0answers
82 views

emacs dired ignores LC_COLLATE=C when using sudo?

My emacs dired changes sort order from ASCII to case-insensitive whenever I view a directory listing under sudo::. Checking getenv on LC_COLLATE shows that emacs still thinks the value is 'C'; and ls -...
2
votes
3answers
140 views

Elisp: sorting SYM VAL pairs in a setq expression

I wrote a rather clunky elisp function to sort the SYM VAL args in a setq expression alphabetically by SYM. For example: (setq c "blah" (setq a 9 b '(more stuff) --> b '(...
1
vote
1answer
286 views

sort lines by regexp

I have a todo list in a text file that I maintain with TaskAgent and emacs. TaskAgent adds trailing text to a line to indicate priority (#!!! represents highest, #! represents low, and no mark is ...
1
vote
1answer
162 views

wanderlust: default summary sort order?

I would like my all my wanderlust *Summary* buffers to be sorted by "number" in "reverse" order. I know how to manually request a sort, but I want this specified sort order to always be the default ...
0
votes
1answer
81 views

Custom function to map through nested lists sorting by time-stamp

In the following example, please assume that we are using time-to-seconds to convert each times-stamp into a decimal representation. I have already converted the time-stamps to seconds in this ...
0
votes
1answer
173 views

org mode sort problems with (numerical) properties

I use the property "pages" for the number of pages of an article or book. There are two problems. First: If I use C-c ^ to sort the items by the value of pages org-sort seems to interpret the ...
0
votes
1answer
55 views

Custom sort order based on certain elements of a list

Q:  Each sub-list within the main list contains one of five possible categories. How can I customize the sort in the following order: CUSTOM SORT ORDER: 1. TASKS 2. EVENTS 3. UNDATED 4. ...
0
votes
1answer
50 views

Idiomatic boolean comparators

Are there idiomatic boolean comparators in emacs lisp? Something like: (my/bool< nil t) => t (my/bool< 1 2) => nil For example, a comparator that returns t if the first argument is ...
2
votes
2answers
1k views

org-agenda-sorting-strategy: items containing no time-of-day specification first

The manual says For the daily/weekly agenda, the items for each day are sorted. The default order is to first collect all items containing an explicit time-of-day specification. 8:30-13:...
2
votes
1answer
521 views

Reverse suggestions from hippie-expand

I currently have the following settings for hippie-expand in my .emacs file: (setq hippie-expand-try-functions-list '(try-expand-dabbrev try-expand-dabbrev-all-buffers try-expand-dabbrev-...
2
votes
2answers
250 views

org-sort-entries recursively

A natural approach to sorting an outline recursively would be the following: (org-map-entries (lambda () (org-sort-entries nil ?f 'my/sort-function) nil 'tree) ...