# work0602.rb
# ファイルのソート
# 最終アクセス時刻でソート
# 二つの配列変数を使う場合

filelist = Array.new
timelist = Array.new
Dir::foreach(Dir::pwd){|name|
    filelist << name
    timelist << File::atime(name)
}

j = timelist.size - 1

while j > 0 do
    i = 0
    while i < j do
        if timelist[i] > timelist[i+1]
            tmp = timelist[i]
	    timelist[i] = timelist[i+1]
	    timelist[i+1] = tmp
	    tmp = filelist[i]
	    filelist[i] = filelist[i+1]
	    filelist[i+1] = tmp
        end
	i += 1
    end
    j -= 1
end

for i in 0...timelist.size do
    print timelist[i],":",filelist[i],"\n"
end