Java tutorial
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Attr; import org.w3c.dom.NamedNodeMap; public class Main { /** Returns a sorted list of attributes. * * @param attrs A map of attributes * @return A sorted array of attributes */ protected static Attr[] sortAttributes(NamedNodeMap attrs) { int len = (attrs != null) ? attrs.getLength() : 0; Attr array[] = new Attr[len]; for (int i = 0; i < len; i++) { array[i] = (Attr) attrs.item(i); } /* for (int i = 0; i < len - 1; i++) { String name = array[i].getNodeName(); int index = i; for (int j = i + 1; j < len; j++) { String curName = array[j].getNodeName(); if (curName.compareTo(name) < 0) { name = curName; index = j; } } if (index != i) { Attr temp = array[i]; array[i] = array[index]; array[index] = temp; } } */ return (array); } }