MATLAB: How to move certain rows up or down in a cell array

MATLABshift cellssorting

I have a cell array, which is sorted alphabetically. I need to move any row that contains a marker (for example, X), to the top of the list. How do I do that?
e.g.:
AAA AAB FFF FTD JJJ XXX XXY ZAF ZAE
So, I just need to move XXX and XXY to the beginning, and the rest of the array should remain the same.
Does anyone know of a script to do this automatically?
Thanks

Best Answer

idx=~cellfun('isempty', strfind(yourcell,'X'));
yourcell=yourcell(:).';
yourcell=[yourcell(idx), yourcell(~idx)];