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
1 vote
0 answers
43 views

How to Sort Org-Mode Headings Without Losing Metadata in Emacs?

I am trying to write an elisp function that can sort org headings and move the subtree with the headings while preserving the file metadata. Here is the version information for Emacs and Org and the ...
jwl's user avatar
  • 11
0 votes
1 answer
37 views

org-sort not working properly

Given this org-file as an example: org syntax example ​ * header #+TITLE: Tasks :PROPERTIES: :TMP01: Azat :ID: 123 :END: ​ * hh.2 ** hh.2.1 another date [2019-01-25 Fri] more date <2019-01-25 Fri ...
Alexander Mirnyy's user avatar
0 votes
1 answer
46 views

alphanumeric sort of a region

Assuming your buffer content is similar to this: x1_y1_text_x3_y1 x1_y1_text_x3_y10 x1_y1_text_x3_y11 x1_y1_text_x3_y12 x1_y1_text_x3_y2 x1_y1_text_x3_y3 x2_y1_text_x3_y20 .... how to get the region ...
Clement's user avatar
0 votes
0 answers
31 views

add-to-ordered-list is not placing element at the alphabetic order

I am having an ordered list to which i am trying to add alphabets. But I see, the newly inserted element is placed out of order. This example is taken from gnu manual (setq foo '()) ⇒ nil (add-...
Saravana's user avatar
  • 2,071
2 votes
2 answers
128 views

How do you sort tokens within a line

Sorting lines in Emacs is fairly straightforward with sort-lines. However, how do I sort within a line? For example: John Ringo Paul George -> George John Paul Ringo
Fergie's user avatar
  • 203
1 vote
2 answers
127 views

suppress a completion candidate, or configure the sorting of completion results?

When I do M-x bury, my completion setup (I use fido-mode, along with vertico and marginalia), produces these results: 1/95 M-x bury rmail-bury ... bury-buffer ... unbury-buffer ... (etc etc etc) I ...
Dan Drake's user avatar
  • 615
1 vote
1 answer
55 views

Org mode table column sort in evil mode?

You sort org mode tables using C-c ^ in emacs, but how do you do the same in evil/vim mode?
01AutoMonkey's user avatar
3 votes
2 answers
274 views

How to ignore accents (À Â É Ê etc.) when sorting?

When sorting text with Emacs, the result is wrong for accented characters: Always Emerald Yesterday Zoo À la campagne Âge Écarlate Être Here is the result I would like instead: À la campagne Âge ...
Carapuce's user avatar
3 votes
2 answers
232 views

How to sort structured blocks?

There are cases where I wish to sort data that has been wrapped across multiple lines, making a simple line-sort not work usefully e.g. '("x" "b" "c" "a lot of text&...
ideasman42's user avatar
  • 8,796
4 votes
1 answer
62 views

Display completion options from top to bottom in alphabetical order?

Completion are currently listed in alphabetical order as a b c d e f With alphabetical order going from left to right. How can I can change this to. a c e b d f With alphabetical order going from ...
Progamer's user avatar
1 vote
2 answers
182 views

Sort text by group in markdown

I'm not a tech person. I've been using Neovim for the last year or so for writing, and I love it. But I'm considering making the switch to Emacs for the ability to use non-mono fonts. I use markdown ...
Euth38348's user avatar
0 votes
1 answer
94 views

Sort org-agenda entries chronologically with grid in the middle

Is it possible to get my items sorted in a chronological manner, such that the grid remains in "today" relative to other entries? Something like this: cat1: sched 5 days ago TODO task 1. ...
onlycparra's user avatar
1 vote
2 answers
126 views

Incorporate a list of floats, into another list of floats, in numerical order, with remainders

In this example, there is a list of miscellaneous orphan floats '(9.9 10.1 10.3 10.5 10.7 10.9 11.1) that needs to be incorporated in numerical order into a second main / master list (10.0 10.2 10.4 ...
lawlist's user avatar
  • 19.1k
1 vote
1 answer
54 views

Sorting counts in descending order

Have the following code that counts the number of times words are used. I want to list the results sorted by the number of counts. (defun rk-word-analysis (reg-beg reg-end) "Count ...
Dilna's user avatar
  • 1
0 votes
1 answer
45 views

sort: How to specify the order in which multiple sorts are performed

In the following example, there are two criteria for sorting -- orders with an inactive status should appear last in the last, and all orders should be organized by order number from smallest to ...
lawlist's user avatar
  • 19.1k
-1 votes
2 answers
53 views

Not correct reverse sort in dired mode

Linux Mint 20.2 Emacs 27.2 Installed packages: dired+ dired-hacks-utils-20201005.2318 dired-k-20200322.2035 dired-narrow-20181114.1723 dired-quick-sort-20201221.403 dired-recent-20211004.1924 dired-...
a_subscriber's user avatar
  • 4,074
0 votes
1 answer
87 views

How can I sort a list of buffers according to a buffer-local variable?

I am setting a buffer-local variable called my/tab-order in (some) of my buffers. I have written the following function to return a list of buffers only where my/tab-order has been set and is greater ...
randouser's user avatar
  • 141
0 votes
2 answers
130 views

Sorting lines based on numbers in unicode

I want to sort some text in emacs that is based on a field that contains verse numbers in unicode (devanagari). The text is like this: Verse text bla १०.३ #10.3 Verse text blah This is १.१९ #1.19 ...
linuxfan's user avatar
  • 209
1 vote
1 answer
64 views

Get company to sort single underscore before double underscore, specifically with elpy/python-mode

Edit: this question is a duplicate of this one; I'm leaving it because I got a helpful answer and I didn't find the other one after reasonable amount of searching (so I hope this one being here will ...
Levin's user avatar
  • 143
0 votes
1 answer
59 views

How to activate functions on .org files from within agenda view?

From agenda view, is it possible to execute functions on specific .org files? Example setup: foo.org and bar.org are source files for agenda Example working function from : Sort entire hierarchy in an ...
XLIII's user avatar
  • 13
2 votes
1 answer
178 views

C-x C-f TAB TAB: Find file completion list: how to highlight subdirectories?

Often I'd like to open a file in a subdirectory. But poor me, I can't remember the name. So when typing C-x C-f and then TAB TAB for the completion list, the list of all files in this directory is ...
Keks Dose's user avatar
  • 508
1 vote
1 answer
129 views

The list-buffers command. How to make the 'Buffer' column sort case-insensitively, when click on it?

C-x C-b is normally bound to the list-buffers command. The resulting buffer has various columns, which are CRM, Buffer, Size, Mode, and File. When I can click on the Buffer column-header, it will ...
Rolly's user avatar
  • 11
2 votes
2 answers
38 views

Sort lines omitting a prefix of a certain length?

Many of my python files have an import section that looks like this: from datetime import datetime, timedelta from typing import Callable import numpy as np import pandas as pd I'd like to sort ...
Jeffrey Benjamin Brown's user avatar
1 vote
2 answers
217 views

How to add a string at nth position of an ordered list of strings

The built-in function add-to-ordered-list is for symbols, not strings. I have a list of strings and need to add another string to the list at a specific nth position. How can I accomplish this? TASK:...
lawlist's user avatar
  • 19.1k
0 votes
1 answer
374 views

How can I sort Org headings by value in :properties:

My org file structure is this: * Heading 1 :PROPERTIES: :EVENT_CREATED: [2016-11-28] :END: * Heading 2 :PROPERTIES: :EVENT_CREATED: [2016-10-27] :END: * Heading 3 :PROPERTIES: :EVENT_CREATED: [2019-02-...
Harry's user avatar
  • 1
0 votes
0 answers
95 views

Sorting todos by custom todo label when invoking `org-todo-list` with `C-c a t`

I have defined some custom todos keywords with (setq org-todo-keywords '((sequence "TODO" "TODAY" "IN-PROGRESS" "WAITING" "URGENT" "FUTURE&...
Nisba's user avatar
  • 905
0 votes
0 answers
69 views

Emacs on Windows. Dired - no sorting. Unrecognized symbols

Set up Doom Emacs on windows. Works fine but in Dired i have unrecognized symbols and also in org-capture. Sorting in dired does not work either. Any ideas? Latest Emacs.
Roman Smirnov's user avatar
2 votes
1 answer
111 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-...
Navidot's user avatar
  • 772
0 votes
1 answer
193 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 ...
starquake's user avatar
3 votes
1 answer
204 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 ...
Sati's user avatar
  • 795
2 votes
1 answer
1k 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, ...
Daniel's user avatar
  • 99
2 votes
1 answer
324 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" "...
Sime1's user avatar
  • 31
5 votes
0 answers
311 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 ...
SFbay007's user avatar
  • 584
2 votes
1 answer
405 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?
Prikshet Sharma's user avatar
6 votes
1 answer
2k 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 ...
Ashton Wiersdorf's user avatar
1 vote
2 answers
167 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). ...
ideasman42's user avatar
  • 8,796
1 vote
0 answers
63 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 ...
Edman's user avatar
  • 1,207
1 vote
1 answer
51 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 ...
a_subscriber's user avatar
  • 4,074
0 votes
0 answers
348 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 ...
midas0441's user avatar
  • 304
0 votes
1 answer
68 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 ...
american-ninja-warrior's user avatar
3 votes
1 answer
181 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 ...
rich ratzan's user avatar
1 vote
1 answer
549 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 ...
Alex's user avatar
  • 801
2 votes
1 answer
135 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 ...
Felipe's user avatar
  • 241
2 votes
1 answer
152 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?
Toothrot's user avatar
  • 3,264
1 vote
1 answer
173 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 ...
user1735594's user avatar
7 votes
1 answer
376 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 ...
Dan's user avatar
  • 33k
2 votes
1 answer
162 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, ...
Croad Langshan's user avatar
1 vote
1 answer
465 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-...
John Kitchin's user avatar
  • 11.9k
1 vote
1 answer
141 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 ...
scaramouche's user avatar
  • 1,734
3 votes
1 answer
515 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 ...
Ivan Perez's user avatar