protected void sortRules(ArrayList rules, Element elt, String pseudo) {
int len = rules.size();
int[] specificities = new int[len];
for (int i = 0; i < len; i++) {
StyleRule r = (StyleRule) rules.get(i);
SelectorList sl = r.getSelectorList();
int spec = 0;
int slen = sl.getLength();
for (int k = 0; k < slen; k++) {
ExtendedSelector s = (ExtendedSelector) sl.item(k);
if (s.match(elt, pseudo)) {
int sp = s.getSpecificity();
if (sp > spec) {
spec = sp;
}