 ;;;        (icicle-unbind-file-candidate-keys)))
 ;;;    (and current-prefix-arg  (natnump (prefix-numeric-value current-prefix-arg))
 ;;;         (read-string "Dired listing switches: " dired-listing-switches))))
+
+;;;###autoload
+(defun diredp-sort-arbitrary-command (sort-function)
+  "Sort the current Dired listing of arbitary files.
+
+NOTE:
+ This is intended for sorting a list of arbitrary file names, not an
+ ordinary Dired listing such as produced by `ls'.
+
+ If the current Dired buffer is *not* already a list of arbitrary file
+ names then you are prompted to confirm converting it to such a list.
+ If you do so it will no longer use `ls' or `dired-listing-switches'.
+ Don't confirm, if you don't want this conversion."
+  (interactive
+   (if (and (atom dired-directory)
+            (not (y-or-n-p "Convert Dired buffer to a list of arbitrary file names? ")))
+       (error "OK, canceled")
+     (let* ((cands  '(("2: Reverse"              . t)
+                      ("3: Nondir Name, A-to-Z"  . diredp-nondir-file-name-less-p)
+                      ("4: Nondir Name, Z-to-A"  . diredp-nondir-file-name-more-p)
+                      ("5: Full Name, A-to-Z"    . diredp-full-file-name-less-p)
+                      ("6: Full Name, Z-to-A"    . diredp-full-file-name-more-p)))
+            (order  (completing-read "Sort order: " cands nil t)))
+       (list (cdr (assoc order cands))))))
+  (let ((buf    (buffer-name))
+        (files  (copy-sequence (dired-get-marked-files nil '(64)))))
+    (kill-buffer)
+    (dired (cons buf (if sort-function
+                         (if (functionp sort-function)
+                             (sort files sort-function)
+                           (nreverse files))
+                       files))
+           dired-actual-switches)))
 
 ;;;###autoload
 (defun diredp-dired-union (dired-name dirbufs &optional switches extra) ; Bound to `C-x D U'

  (defcustom diredp-count-.-and-..-flag nil
    "Non-nil means count `.' and `..' when counting files for mode-line."
    :type 'boolean :group 'Dired-Plus))

;;;###autoload
(defcustom diredp-do-report-echo-limit 5

;;
;;; Change Log:
;;
;; 2021/11/30 dadams
;;     diredp-do-apply/eval-marked-recursive:
;;       Typo in body: current-prefix-arg -> arg.  Corrected first argument to diredp-get-files.
;; 2021/10/03 dadams
;;     Added: diredp-toggle-dot+dot-dot-flag.
;;     dired-toggle-marks: Added optional arg FLIP.  Respect diredp-toggle-dot+dot-dot-flag.
;; 2021/09/23 dadams
;;     diredp-menu-bar-multiple-menu: Removed items that are anyway on Apply (Map) submenu.
;; 2021/07/22 dadams
;;     Added: diredp-remove-inserted-subdirs, diredp-fit-one-window-frame.
;;     dired-maybe-insert-subdir: With negative prefix arg, remove all inserted subdir listings.
;;     diredp-fit-frame-unless-buffer-narrowed, diredp-toggle-marks-in-region: Use diredp-fit-one-window-frame.
;; 2021/06/21 dadams
;;     dired-buffers-for-dir: Updated for Emacs 28: Added optional arg SUBDIRS.
;;     diredp-dired-inserted-subdirs, diredp-next-subdir: dired-get-subdir-min -> cdr (Emacs 27 removed it).
;;     dired-get-filename: Updated per Emacs 27: Removed Emacs 22-26 string-to-multibyte hack.
;;     dired-do(-flagged)-delete: Applied fix for bug #48805.
;;     dired-mark-pop-up: Updated per Emacs 27+: Reset tab-line-exclude to nil.
;; 2021/06/16 dadams
;;     diredp--dired-recent-files-1: Bug fix in generated rev-fn: use BUFNAME, not BUFFER.
;; 2021/06/07 dadams
;;     Added redefinitions of dired-repeat-over-lines and dired-toggle-marks (bug #48883).
;; 2021/05/10 dadams
;;     diredp-copy-filename-as-kill-recursive: use diredp-filename-separator, not SPC.
;;     dired-copy-filename-as-kill, diredp-yank-files: Mention diredp-filename-separator in doc string.
;;     diredp-copy-abs-filenames-as-kill-recursive: Corrected doc string to mention diredp-last-copied-filenames.
;; 2021/04/20 dadams
;;     Added: dired-move-to-filename, and made it a command.
;; 2021/04/14 dadams
;;     diredp-menu-bar-dir-menu: Added dired-undo.
;; 2021/03/20 dadams
;;     Added: diredp--dired-recent-files-1.
;;     diredp-recent-files-buffer is for dirs also now.
;;     diredp-dired-recent-(files|dirs)(-other-window):
;;       Added FILES arg.  Use diredp--dired-recent-files-1.  Revert-buffer respects prefix arg, else relists same.
;;     diredp-read-include/exclude: Added optional arg keep-duplicates-p.  Delete dups by default.
;; 2021/03/19 dadams
;;     Added: diredp-case-fold-search, diredp-default-sort-arbitrary-function, diredp-sort-arbitrary-command,
;;            diredp-sort-arbitrary, diredp-string-less-p, diredp-(full|nondir)-file-name-(less|more)-p.
;;     diredp-dired-recent-(files|dirs)(-other-window): Apply diredp-sort-arbitrary.
;;     diredp-dired-recent-dirs(-other-window): Made revert-buffer-function a local var (forgot this).
;;     diredp-sort-arbitrary-command: Add to diredp-menu-bar-dir-menu and bind to C-M-L.
;; 2021/03/10 dadams
;;     Added: diredp-copy-as-kill-from-clipboard.
;;     diredp-yank-files: You can now also yank the file names from the clipboard.
;; 2021/03/03 dadams
;;     Renamed: diredp-omit-files-regexp to diredp-omit-files-font-lock-regexp,
;;              diredp-omit-line-regexp to diredp-omit-lines-regexp.
;;     diredp-omit-lines-regexp: Value can also be a variable whose value is a regexp.
;;     dired-omit-expunge: If REGEXP is a variable, use its value.
;; 2021/03/02 dadams
;;     Added: diredp-omit-line-regexp, redefinitions of dired-do-kill-lines, dired-omit-expunge, dired-omit-mode.
;; 2021/02/07 dadams
;;     Added: diredp-mark.  Give it dired-mark's keys.
;;     diredp-mark-region-files: Non-negative prefix arg now prompts for the CHAR to mark with.
;; 2021/02/04 dadams
;;     diredp-mark(-region-files)-with-char: Updated since bug #46243 is now fixed (for Emacs 28+).
;; 2021/02/01 dadams
;;     Added: diredp-mark-region-files-with-char, diredp-mark-with-char.
;;     diredp-marks-mark-menu, diredp-mouse-3-menu: Added items for diredp-mark(-region-files)-with-char.
;; 2021/01/02 dadams
;;     Updates for Emacs 27.1.
;;       dired-map-over-marks-check: Use ngettext for Emacs 27.
;;       dired-do-search, dired-do-query-replace-regexp: Use fileloop-initialize-(search|replace) for Emacs 27.
;;       dired-do-find-regexp: Require xref.el.  Map over rgrep-find-ignored-directories.
;;                             For Emacs 27+, xref--show-xrefs needs a fetcher function, not a file list.
;; 2020/12/27 dadams
;;     dired(p)-do-find-marked-files(-recursive): Don't pass plain C-u as arg to dired-simultaneous-find-file.
;; 2020/12/05 dadams
