最新の日付から古い日付までの日付を一覧表示したい。
使いたくないCollections.sort()
ので、独自の方法を作りました。
私がこれを行うとき:
List<Livre> maBibliotheque = new ArrayList<Livre>();
boolean tri = false;
int born = maBibliotheque.size();
while (tri == false)
{
tri = true ;
for (int i=0; i<born-1;i++)
{
if ( maBibliotheque.get(i).getNewPeriode().compareTo(maBibliotheque.get(i+1).getNewPeriode())>0){
Livre livre = maBibliotheque.get(i);
maBibliotheque.set(i, maBibliotheque.get(i+1));
maBibliotheque.set(i+1,livre);
tri = false ; }
}
born -= born;
}
それは完全に機能しますが、最も古い日付から最新の日付までですが、それ以外が必要です。この行を次のように変更します
if ( maBibliotheque.get(i).getNewPeriode().compareTo(maBibliotheque.get(i+1).getNewPeriode())<0){
しかし、それは何もしません。この場合、ソート日付はありません。助けてください