2022 Developer Survey is open! Take survey.

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
0 votes
1 answer
28 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. ...
user avatar
1 vote
2 answers
121 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 ...
user avatar
  • 17.6k
1 vote
1 answer
39 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 ...
user avatar
  • 159
0 votes
1 answer
34 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 ...
user avatar
  • 17.6k
0 votes
0 answers
32 views

How to force emacs to save the entries of abbrev_defs file chronologically (instead of alphabetically)?

By default, the entries of the abbrev_defs file are sorted alphabetically, something like below. Is it possible to force emacs to save the entries by chronological order? That is, the abbreviations ...
user avatar
  • 7,284
-1 votes
2 answers
29 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-...
user avatar
  • 3,395
0 votes
1 answer
37 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 ...
user avatar
0 votes
2 answers
93 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 ...
user avatar
  • 169
1 vote
1 answer
42 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 ...
user avatar
0 votes
1 answer
45 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 ...
user avatar
  • 13
0 votes
0 answers
40 views

How to capture the column sort in Org-mode inside a formula?

Let's say, I have a following table: |-------+---------| | NAME | VALUE | |---------+-------| | DAVID | 3.83 | | JULIA | 0.89 | | ALICE | 0.59 | |-------+---------| | SUM | ...
user avatar
  • 3,715
0 votes
0 answers
22 views

Sorting entries by effort using org-ql

I can sort today's todos by priority using org-ql with (org-ql-search (org-agenda-files) '(ts-active :on today) :sort 'priority) ;; By the way, this lists the todo's that are DONE. I hope to ...
user avatar
  • 215
2 votes
1 answer
67 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 ...
user avatar
  • 474
1 vote
1 answer
52 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 ...
user avatar
  • 11
2 votes
2 answers
30 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 ...
user avatar
1 vote
2 answers
74 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:...
user avatar
  • 17.6k
0 votes
1 answer
120 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-...
user avatar
  • 1
0 votes
0 answers
73 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&...
user avatar
  • 835
0 votes
0 answers
38 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.
user avatar
2 votes
1 answer
72 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-...
user avatar
  • 592
0 votes
1 answer
75 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 ...
user avatar
3 votes
1 answer
152 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 ...
user avatar
  • 635
1 vote
1 answer
484 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, ...
user avatar
  • 59
2 votes
1 answer
98 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" "...
user avatar
  • 31
5 votes
0 answers
171 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 ...
user avatar
  • 554
1 vote
1 answer
211 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?
user avatar
3 votes
1 answer
1k 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 ...
user avatar
1 vote
2 answers
135 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). ...
user avatar
  • 7,069
1 vote
0 answers
59 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 ...
user avatar
1 vote
1 answer
35 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 ...
user avatar
  • 3,395
0 votes
0 answers
255 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 ...
user avatar
  • 154
0 votes
1 answer
54 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 ...
user avatar
2 votes
1 answer
119 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 ...
user avatar
1 vote
1 answer
404 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 ...
user avatar
  • 761
2 votes
1 answer
117 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 ...
user avatar
  • 199
2 votes
1 answer
94 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?
user avatar
  • 2,904
1 vote
1 answer
99 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 ...
user avatar
7 votes
1 answer
257 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 ...
user avatar
  • 31k
2 votes
1 answer
110 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, ...
user avatar
1 vote
1 answer
339 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-...
user avatar
  • 10.9k
1 vote
1 answer
101 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 ...
user avatar
  • 1,740
3 votes
1 answer
257 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 ...
user avatar
0 votes
2 answers
106 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 ...
user avatar
  • 731
2 votes
1 answer
266 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-...
user avatar
  • 142
0 votes
1 answer
120 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 ...
user avatar
  • 123
2 votes
1 answer
211 views

Sort entire hierarchy 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 *** 2 *** 3 ** C *** 1 **...
user avatar
  • 1,668
0 votes
1 answer
113 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 ...
user avatar
0 votes
1 answer
52 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. ...
user avatar
  • 7,069
0 votes
1 answer
233 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 ...
user avatar
  • 17.6k
1 vote
0 answers
55 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; ...
user avatar
  • 821