-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment1CovidCasesWithoutTabularForm.dart
More file actions
70 lines (62 loc) · 3.17 KB
/
Assignment1CovidCasesWithoutTabularForm.dart
File metadata and controls
70 lines (62 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// https://www.covid19india.org/
//CovidCases
void main()
{
Map Maharashtra={'Confirmed': 6229596, 'Active':94593,'Recovered':6000911, 'Deceased':130753};
Map Kerala={'Confirmed': 3187716, 'Active':126396,'Recovered':3045310, 'Deceased':15512};
Map Karanataka={'Confirmed': 2886702, 'Active':26256,'Recovered':2824197, 'Deceased':36226};
Map TamilNadu={'Confirmed': 2539277, 'Active':26717,'Recovered':2478778, 'Deceased':33782};
Map AndhraPradesh={'Confirmed': 1946749, 'Active':23939,'Recovered':1909613, 'Deceased':13197};
Map UttarPradesh={'Confirmed': 1708005, 'Active':1036,'Recovered':1684230, 'Deceased':22739};
var states={'Maharashtra': Maharashtra,'Kerala': Kerala, 'Karanataka': Karanataka, 'TamilNadu':TamilNadu, 'AndhraPradesh':AndhraPradesh,'UttarPradesh': UttarPradesh};
List stateskeys=states.keys.toList();
List statesvalues=states.values.toList();
// print(stateskeys);
// print(statesvalues);
print("#############################################################################################################################################");
print("\t\t\t\t\tStates with number of cases ");
print("#############################################################################################################################################");
for(int i=0;i<statesvalues.length;i++)
{
print("| \t ${stateskeys[i]} \t | \t ${statesvalues[i]} \t |");
}
List caseskeys=statesvalues[0].keys.toList();
print("\n\n");
print("****************************************************************************************************************************");
print("Types of cases are : ${caseskeys}");
for(int p=0;p<caseskeys.length;p++)
{
print("${caseskeys[p]}: ${p}");
}
print("put variable typeofcases value to 0/1/2/3 according to what you need for sorting according to that cases.");
//Sorting starts
int typeofcases=3;
print("for the time being, typeofcases=${typeofcases}--> ${caseskeys[typeofcases]}");
print("******************************************************************************************************************************");
print("\n\n\n");
for (int j=0;j<statesvalues.length;j++)
{
for (int k=j+1; k<statesvalues.length;k++)
{
if (statesvalues[k][caseskeys[typeofcases]]<statesvalues[j][caseskeys[typeofcases]])
{
for(int m=0;m<caseskeys.length;m++)
{
int temp=statesvalues[j][caseskeys[m]];
statesvalues[j][caseskeys[m]]=statesvalues[k][caseskeys[m]];
statesvalues[k][caseskeys[m]]=temp;
}
String temp2=stateskeys[j];
stateskeys[j]=stateskeys[k];
stateskeys[k]=temp2;
}
}
}
print("#############################################################################################################################################");
print("\t\t\t\t\tAfter sorting according to the ${caseskeys[typeofcases]} cases in descending order.");
print("#############################################################################################################################################");
for(int i=0;i<statesvalues.length;i++)
{
print("| \t ${stateskeys[i]} \t | \t ${statesvalues[i]} \t |");
}
}