if efficiency does not matter, brute-force it
(for school this probably won´t count!)
i.e. calculate all possible permutations of cities, then calculate the length of the way and then
- if you want to sort by length, search on google for "quicksort".
- if you only want the shortest and longest paths, find them in a single loop.
how many cities are there?
the number of loops max. needed is x.
all permutations for a given number n of cities are calculated as
x=n! = n*(n-1)*(n-2)*...*1
if your cpu can handle this many tries in a "normal" time, this is imho your "easiest" way.