I want to sort the following based on their keys
case IndexError:
PyErr_SetString(PyExc_IndexError, exc.str.c_str());
break;
case ValueError:
PyErr_SetString(PyExc_ValueError, exc.str.c_str());
break;
case RuntimeError:
PyErr_SetString(PyExc_RuntimeError, exc.str.c_str());
break;
case IOError:
PyErr_SetString(PyExc_IOError, exc.str.c_str());
break;
so it becomes
case IOError:
PyErr_SetString(PyExc_IOError, exc.str.c_str());
break;
case IndexError:
PyErr_SetString(PyExc_IndexError, exc.str.c_str());
break;
case RuntimeError:
PyErr_SetString(PyExc_RuntimeError, exc.str.c_str());
break;
case ValueError:
PyErr_SetString(PyExc_ValueError, exc.str.c_str());
break;
Essentially, I am only sorting the lines
case IOError:
case IndexError:
case RuntimeError:
case ValueError:
The contents of the other lines (the ones that do not begin with a case
) do not matter but I want them to be sorted with the cases.
case
s are similar, you could regenerate the whole thing. Get the sorted*Error
s (from anenum
? Maybe run throughsort(1)
?), then make a macro that convertsXError
tocase XError: PyErr_SetString(PyExc_XError, exc.str.c_str()); break;
and run it for all the enum values.