Sorting across rows in libreoffice

I have a table like so: - it has some blanks

A1 B1 C1 - A1 B1 C1
V1 B1 0/1 C1 0/0 A1 1/1 -
V2 C1 0/1 A1 0/0 B1 0/1 -
V3 B1 0/0 A1 0/1 -

etc

I would like to shuffle each row around so they fall in the correct column, so in a way sort across rows but not move the data vertically, only horizontally as each row is specific to the V number.

How would I do this in calc?

Many thanks

EDIT: table format applied by LeroyG, following erAck link.

1 Like

It’s not really clear. You have to show the end result.

Please format a table as table … see This is the guide - How to use the Ask site? - #6 by erAck .
Without that, with blanks being ignored in the HTML output it’s not even clear what your original data would be.

@tacrolimus,
Can you edit your question, and add the expected result at the right side of the table? Thanks.

I’ll guess the OP means

At least, that’s an interesting question…to get the entries to “pop” under their correct column. Can’t see how data would get entered as shown, but, academically, it’s interesting to fix with automation. :neutral_face:

If correct assumption, I see it as a lookup problem, not as a sorting problem:

=IFERROR(INDEX($C6:$E6,1,MATCH(CONCATENATE(M$5,"*"),$C6:$E6,0)),"")

in each cell of a parallel table. (See the example ODS.)

SnapEntriesToHeaders.ods (12.6 KB)

1 Like

+1
I love the simplicity of this solution (macros, rightfully, cause security warnings).

But it should be mentioned that this needs “Enable wildcards in formulas” to be set.
(The attached example helped tracking down that I had regular expressions enabled.)

sortColumns.ods (18.9 KB)

1 Like
Sub sortColumns_of_UsedArea(e)
	bAsc = cBool(e.Source.Model.Tag)

There’s a takeaway…thanks.