Merged cells are the spawn of the devil and should be avoided at all costs (as you have discovered). There are other ways of formatting (center across selection) to give the same visual effect. To be able to sort you will need to lose (i.e. unmerge) the merged cells.
If you haven't deliberately merged any cells, you can use the following macro.
Dim c As Range, mcells As Long
mcells = 0
For Each c In ActiveSheet.UsedRange
If c.MergeCells = True Then
mcells = mcells + 1
MsgBox c.Address(False, False) & " is merged"
MsgBox "Total of " & mcells & " merged cells found"
To use this, press ALT + F11 to open the Visual Basic Editor. Insert > Module then copy the above code and paste it in. Close the VBE. On your sheet Tools > Macro > Macros, highlight 'test' and click the run button.