TeX - LaTeX Asked on April 27, 2021
I sorted a table by X
-values ascending.
There are several equal X
-values and I need them to be sorted by there corresponding Z
-values descending.
And maybe ascending Y
-values, if X
-values are equal each other and X
-values are equal each other.
That means in detail:
Is there an elementary way, to configure the sort key?
documentclass[a4paper]{article}
usepackage{pgfplotstable}
pgfplotsset{compat=1.17}
usetikzlibrary{calc}
usepackage{subcaption}
defpgfmathsetglobalmacro#1#2{pgfmathparse{#2}%
globallet#1pgfmathresult}
pgfplotstableset{
every head row/.style={after row=hline},
every even row/.style={after row=hline},
every odd row/.style={after row=hline},
}
begin{document}
pgfplotstableread[col sep=comma,header=true]{
X, Y, Z
10, 1, 5
2, 1, 5
2, 0, 5
1, 0, 5
0, 0, 5
0, 1, 10
1, 5, 11
1, 12, 11
}{datatable}
pgfplotstablesort[sort key=X, sort cmp=int <]xsorttable{datatable}
begin{table}[!htb]
begin{subtable}{.25linewidth}
centering
caption{Original Table}
pgfplotstabletypeset[]{datatable}%
end{subtable}
begin{subtable}{.25linewidth}
centering
caption{X-Sorted Table}
pgfplotstabletypeset[]{xsorttable}%
end{subtable}
end{table}
end{document}
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP