Question: the program will reorder the list so the resulting list is sorted. { array: [ Python, C++, Java, C#, Swift, JavaScript, PHP, C, Perl, VB,

the program will reorder the list so the resulting list is sorted.

{ "array": [ "Python", "C++", "Java", "C#", "Swift", "JavaScript", "PHP", "C", "Perl", "VB", "Kotlin" ] }

expected output :

What is the name of the file? languages.json The values in languages.json are: C C# C++ Java JavaScript Kotlin PHP Perl Python Swift VB

my code:

import json

filename = input('What is the name of the file? ')

with open(filename) as f:

data = json.load(f)

print(len(data['array']))

for i in range(len(data['array']),1,-1):

print(i)

i_check = i

i_largest = i_check

for j in range(len(data['array'])-1,0,-1):

print(j)

if data['array'][j] > data['array'][i_largest]:

i_largest = j

if i_largest != i_check:

data['array'][i_largest],data['array'][i_check] = data['array'][i_check],data['array'][i_largest]

print(data['array'])

could you explain what is wrong with my code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!