Bug 141042 - Feature request: add a new function REVERSE(string)
Summary: Feature request: add a new function REVERSE(string)
Status: RESOLVED INVALID
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: needsUXEval
Depends on:
Blocks: Calc-Function
  Show dependency treegraph
 
Reported: 2021-03-15 08:38 UTC by tagishsimon
Modified: 2023-12-30 22:10 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tagishsimon 2021-03-15 08:38:40 UTC
Request for a new calc function, REVERSE(string), which reverses the order of characters in a string.

REVERSE("ABC") = CBA
A1=123
REVERSE(A1) = 321

Use case: provides a mechanism for sorting a list based on the end of strings rather than the start of strings - I'm working through long lists of geolocatable items and/or organisations & want to draw together location types or organisation types that have the same characteristics. I've found in practice that being able to sort by the reverse of a string nicely groups set of things.

Illustration: https://twitter.com/Tagishsimon/status/1358616303226019847
Comment 1 m_a_riosv 2021-03-15 19:19:36 UTC
You can solve it with a formula like:
=TRANSPOSE(TEXTJOIN("";1;MID($A$1;LEN($A$1)-ROW(OFFSET($ZZ$1;0;0;LEN($A$1);1))+1;1)))
Change the reference cell $A$1 for whatever you like.
Comment 2 Andy Mabbett 2021-12-10 17:29:39 UTC
I second this request. 

The use-case in the linked tweet mirrors my own. On one hand, having the request satisfied would increase the productivity of my pro bono work for Wikipedia and Wikidata; on the other, it is generically applicable across multiple scenarios.


While I appreciate that a formula has been kindly provided by m.a.riosv, a function will be more convenient to use and less error prone.
Comment 3 Buovjaga 2023-05-29 09:15:37 UTC
I could not find such a function for Excel (just tried to find documentation online). Would it be a compatibility problem to add it?
Comment 4 Heiko Tietze 2023-05-30 08:23:09 UTC
(In reply to Buovjaga from comment #3)
> I could not find such a function for Excel (just tried to find documentation
> online). Would it be a compatibility problem to add it?

Likely a showstopper. And Miguel shared a solution that is working out of the box. Could imagine that this also can be done with Regex.
Comment 5 Heiko Tietze 2023-06-05 09:11:37 UTC
No further comment, let's stick to the c1 solution.