It is hard to tell from your post, but I am assuming the text you want to sort and concatenate are located in individual cells,
not all in one cell separated by spaces. Given that, below is a UDF (user defined function) which will do what you want. The function takes two required argument (the range of cells whose values you want to sort and concatenate and the text delimiter you want to put between them) and one optional argument (which allows you to reverse the sort from ascending to descending by passing in TRUE for it). Also note that this function ignores empty cells within the specified range.
Code:
[table="width: 500"]
[tr]
[td]Function CellSorter(Rng As Range, Delimiter As String, Optional ReverseIt As Boolean) As String
Dim Cell As Range
With CreateObject("System.Collections.ArrayList")
For Each Cell In Rng
If Len(Cell.Value) Then .Add Application.Trim(Cell.Value)
Next
.Sort
If ReverseIt Then .Reverse
CellSorter = Join(.ToArray, Delimiter)
End With
End Function
[/td]
[/tr]
[/table]
HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use
CellSorter just like it was a built-in Excel function. For example,
=CellSorter(A2:C2,"_")
If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.C