#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

int main()
{
	char wordList[] = "_cT68est aaa xyz abc_79d A_bcd usw8 bWort";

	struct wordInformation
	{
		char const* pos;
		std::size_t len;
	};

	std::vector<wordInformation> vec;
	vec.reserve( sizeof(wordList) / 5 ); // Durchschnittliche Wortlänge +1

	bool last_char = false;
	for( auto p = wordList; p != wordList + sizeof(wordList) - 1; ++p )
	{
		if( !std::isspace(*p) )
		{
			if(!last_char)
			{
				vec.push_back({p, 1});
				last_char = true;
			}
			else
				++vec.back().len;
		}
		else if(last_char)
			last_char = false;
	}

	std::sort( std::begin(vec), std::end(vec), [](wordInformation const& p1,
	                                              wordInformation const& p2)
	                                           { return std::lexicographical_compare(p1.pos, p1.pos + p1.len,
	                                                                                 p2.pos, p2.pos + p2.len); } );

	char sortedWordList[sizeof(wordList)];

	auto ptr = sortedWordList;
	for( auto& info : vec )
	{
		while( info.len-- )
			*ptr++ = *info.pos++;

		*ptr++ = ' ';
	}

	sortedWordList[sizeof(sortedWordList)-1] = '\0';
	std::cout << sortedWordList;
}
