以下for-each循环只获取X的第一个值..而实际上并没有找到最大值,请你告诉我这里的问题。
public class MasterResponse extends RequestStatus{
private List<Object> data;
public MasterResponse() {
init();
}
public MasterResponse(boolean _success, String _message){
super(_success, _message);
init();
}
private void init(){
this.data = new ArrayList<Object>();
}
public void addModel(Object newModel){
this.data.add(newModel);
}
public void clearData(){
this.data=null;
}
public List<Object> getData() {
return data;
}
public void setData(List<Object> data) {
this.data = data;
}
}
答案 0 :(得分:1)
要以数字方式对这么大的数字序列进行排序,您可以将它们分成子串并按每个子串分别排序 - 例如:
<强> XML 强>
<input>
<item>123456789.0123456780</item>
<item>123456789.0123456781</item>
<item>123456789.0123456782</item>
<item>123456789.0123456783</item>
<item>123456789.0123456784</item>
<item>123456789.0123456785</item>
<item>123456789.0123456786</item>
<item>123456789.0123456787</item>
<item>123456789.0123456788</item>
<item>123456789.0123456789</item>
<item>123456789.012344</item>
<item>123456789.012346</item>
</input>
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/input">
<output>
<xsl:for-each select="item">
<xsl:sort select="substring-before(., '.')" data-type="number" order="descending"/>
<xsl:sort select="concat('0.', substring-after(., '.'))" data-type="number" order="descending"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</output>
</xsl:template>
</xsl:stylesheet>
<强>结果强>
<?xml version="1.0" encoding="UTF-8"?>
<output>
<item>123456789.012346</item>
<item>123456789.0123456789</item>
<item>123456789.0123456788</item>
<item>123456789.0123456787</item>
<item>123456789.0123456786</item>
<item>123456789.0123456785</item>
<item>123456789.0123456784</item>
<item>123456789.0123456783</item>
<item>123456789.0123456782</item>
<item>123456789.0123456781</item>
<item>123456789.0123456780</item>
<item>123456789.012344</item>
</output>