Du musst bei der tabularx-Umgebung natürlich auch eine (maximale) Tabellenbreite angeben und sinnvoll ist die Umgebung auch nur, wenn du min. eine X-Spalte verwendest. Sinnvoll ist dann noch, den Kopf mit \endhead zu markieren.
Angewendet auf dein Beispiel:
\documentclass{article}
\usepackage{etoolbox}
\usepackage{ltablex}
\usepackage{booktabs}
\makeatletter
% #1 - comparator
% #2 - token list to sort
\newcommand\sort[2]{%
\ifstrempty{#2}
{}% else
{%
\sort@begin#1{}#2\sort@s\sort@begin
}%
}
% helpers
\def\sort@s{\sort@s}
\def\ifsort@s#1{%
\ifx\sort@s#1%
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
% #1 - comparator
% #2 - tokens processed so far
% #3 - smallest token so far
% #4 - rest of the list
\def\sort@begin#1#2#3#4\sort@begin{%
\ifsort@s{#4}
{%
\sortend{#3}%
\sort#1{#2}%
}% else
{%
\sort@go#1{#2}{#3}#4\sort@go
}%
}
% #1 - comparator
% #2 - tokens processed so far
% #3 - smallest token so far
% #4 - token under consideration
% #5 - rest of the list
\def\sort@go#1#2#3#4#5\sort@go{%
#1{#3}{#4}{\sort@output#1{#2}{#5}}%
}
% #1 - comparator
% #2 - tokens processed so far
% #3 - rest of the list
% #4 - smaller of the two tokens
% #5 - larger of the two tokens
\def\sort@output#1#2#3#4#5{%
\ifsort@s{#3}
{%
\sortoutput{#4}%
\sort#1{#2{#5}}%
}% else
{%
\sort@begin#1{#2{#5}}{#4}#3\sort@begin
}%
}
\def\sort@numlt#1#2#3{%
\ifnumcomp{#1}<{#2}
{#3{#1}{#2}}% else
{#3{#2}{#1}}%
}
\def\sort@numgt#1#2#3{%
\ifnumcomp{#1}>{#2}
{#3{#1}{#2}}% else
{#3{#2}{#1}}%
}
\def\sort@alpha#1#2#3{%
\ifnumcomp{\pdfstrcmp{#1}{#2}}<{0}
{#3{#1}{#2}}% else
{#3{#2}{#1}}%
}
\def\sort@firstcol#1#2{%
\expandafter\expandafter\expandafter
\sort@fc@helper\expandafter#1#2#1#2%
}
\def\sort@fc@helper#1\\#3\\#5#6#7{%
\ifnumcomp{\pdfstrcmp{#1}{#3}}<{0}
{#7{#5}{#6}}% else
{#7{#6}{#5}}%
}
\newcommand*\sortnumlt{\sort\sort@numlt}
\newcommand*\sortnumgt{\sort\sort@numgt}
\newcommand*\sortalpha{\sort\sort@alpha}
\newcommand*\sortfirstcol{\sort\sort@firstcol}
\makeatother
% Change these to change out the sort outputs.
\newcommand*\sortoutput[1]{#1}
\newcommand*\sortend[1]{#1}
\begin{document}
\def\rowa {$m$ & $kg$ & Masse \\}
\def\rowb {$F$ & $N$ & Kraft \\}
\def\rowc {$h$ & $m$ & Höhe \\}
\begin{tabularx}{\textwidth}{ccX}
\toprule
\textbf{Variable} & \textbf{SI-Einheit} & \textbf{Bedeutung}\\
\midrule
\endhead
\sortfirstcol{\rowa\rowb\rowc}
\bottomrule
\end{tabularx}
\end{document}
Funktioniert im Online-Editor.
BTW: Zusätzlich zur [d]ltablex[/d]-Anleitung sollte man natürlich auch die [d]tabularx[/d]-Anleitung und die [d]longtable[/d]-Anleitung lesen. Schließlich ist
ltablex eine Vereinigung dieser beiden Pakete.
Und zukünftig zeigst du bitte, was angeblich nicht funktioniert und zitierst ggf. auch Fehlermeldungen. "Funktioniert nicht" ist jedenfalls keine auch nur annähernd hinreichende Problembeschreibung! Siehe auch:
Minimalbeispiel