sis = file("file.sis", "r")
val = file("file.val", "wt")

n = int(sis.readline().strip())

la = sis.readline().strip()


alist = []
for i in xrange(n):
  line = sis.readline().strip()
  alist.append(line.split())
    

for i in xrange(n):
  print map(int, alist[i][0].split(":")), map(int, alist[i][1].split(":"))

In:

07:34 08:55 10 20
08:25 09:00 10 20

Out:

08:25 09:00 10 20
07:34 08:55 10 20
Comments
Unclear request

I wish sort "times" in order of size.

17:35
14:24
18:44

Sorted:

14:24
17:35

Pointless forum.

In:
07:34 08:55 10 20
08:25 09:00 10 20
Out:
08:25 09:00 10 20
07:34 08:55 10 20

For a reverse order sort like this, you simply compare for greater instead of lesser, which Python sorts will do with the reverse=True parameter set. Do you also want to take into account the "10 20" which I assume is a date?

Edited 5 Years Ago by woooee: n/a

For a reverse order sort like this, you simply compare for greater instead of lesser, which Python sorts will do with the reverse=True parameter set. Do you also want to take into account the "10 20" which I assume is a date?

sis = file("file.in", "r")
val = file("file.out", "wt")

n = int(sis.readline().strip())

lao_andmed = sis.readline().strip().split()

def lahaeg(tund, minut, kulunud):
  if minut == 0:
    tund = tund - 1
    minut = 60 - kulunud
  return tund, minut

#print "Ladu: ", lao_andmed

alist = []
for i in xrange(n):
  line = sis.readline().strip()
  alist.append(line.split())
 
temp = [] 
for j in xrange(n): 
  new = alist[j][0].split(":"), alist[j][1].split(":")    
  temp.append(new)

temp = sorted(temp, reverse = True)

print temp

Seems work, but it's ugly code?

"""
06:00 23:00 20 10
07:00 08:00 10 20
08:00 09:00 10 20
"""

10, 20 etc are not important now.

Edited 5 Years Ago by -ordi-: n/a

This article has been dead for over six months. Start a new discussion instead.