【发布时间】:2021-08-10 14:03:28
【问题描述】:
我想订购节点选择的字符串变量。这是明天的作业。
public void sortSongName() {
DefaultSongs sortedList = new DefaultSongs();
int temp= Integer.MAX_VALUE;
Song curr=root;
Song hold = null;
while(root.nextSong != null) {
if(curr.getSongName().charAt(0)<hold.getSongName().charAt(0)) {
hold=curr;
curr=root.nextSong;
}else {
curr=root.nextSong;
}
sortedList.createSong(root.nextSong.getSongName(),root.nextSong.getBandName() , root.nextSong.getDuration());
deleteSong(root.nextSong.getSongName());
sortSongName();
}
}
【问题讨论】:
-
您好,欢迎您。请阅读Under what circumstances may I add "urgent" or other similar phrases to my question, in order to obtain faster answers? TL;DR:我们不在乎,它给人的印象是傲慢。
-
关于您的代码,这将有助于了解您的输入和预期/实际输出是什么。据我所知,您只是按歌曲名称的第一个字母排序。这是你所期望的吗?
-
对于为什么不能使用标准库中现有的排序方法有什么限制吗?
-
请提供课程:
DefaultSongs,Song
标签: java linked-list alphabetical-sort