给定以下数据类型
public class FileDefinition
{
public String headercode;
public String text;
public String fileext;
public int readNumBytes;
public FileDefinition(String headercode, String fileext, String text, int readNumBytes)
{
this.headercode = headercode;
this.fileext = fileext;
this.text = text;
this.readNumBytes = readNumBytes;
}
}
我有这样的事情:
knownfiles[90] = new FileDefinition(
"^2E524543",
"ivr",
"RealPlayer video file (V11 and later)",
DEFAULT_READ_BYTES
);
knownfiles[89] = new FileDefinition(
"^.{2,4}2D6C68",
"lha",
"Compressed archive file",
DEFAULT_READ_BYTES
);
knownfiles[88] = new FileDefinition(
"^2A2A2A2020496E7374616C6C6174696F6E205374617274656420",
"log",
"Symantec Wise Installer log file",
DEFAULT_READ_BYTES
);
问题:如何按“headercode”字段排序?
FileDefinition[] filedefs = clsFiledefs.getFileDefinitions();
FileDefinition[] filedefs2 = SOMEMAGIC(filedefs);
我需要它来让我的数组按最长字段排序到最短。
我试过了Array.Sort(X,y)
,但是没有用。提前感谢所有答案。