@@ -330,15 +330,22 @@ func PlotTime(plt Plotter, cfg Config, t time.Time) error {
330330
331331// createTimeInfos creates the time info strings for all locations.
332332func createTimeInfos (cfg Config , t time.Time ) (timeInfos []string , times []* time.Location , err error ) {
333- // Init
334- timeInfos = make ([]string , len (cfg .Timezones )+ 1 )
335-
336- // Prepare timeZones to plot
333+ // Sort timezones and convert
337334 timeZones := make ([]* time.Location , len (cfg .Timezones )+ 1 )
338335 descriptions := make ([]string , len (cfg .Timezones )+ 1 )
336+ sortedTimeZones := sortLocations (cfg .Timezones , cfg .Sorting )
337+
338+ // Prepare timeZones to plot
339339 timeZones [0 ] = time .Local
340340 descriptions [0 ] = "Local"
341- for i , tz := range cfg .Timezones {
341+ sortedZones := cfg .Timezones
342+ switch cfg .Sorting {
343+ case SortingModeOffset :
344+ sortedZones = sortByOffset (cfg .Timezones )
345+ case SortingModeName :
346+ sortedZones = sortByName (cfg .Timezones )
347+ }
348+ for i , tz := range sortedZones {
342349 // Get timezone
343350 loc , err := time .LoadLocation (tz .TZ )
344351 if err != nil {
@@ -350,6 +357,7 @@ func createTimeInfos(cfg Config, t time.Time) (timeInfos []string, times []*time
350357 }
351358 descriptionLength := maxStringLength (descriptions )
352359
360+ timeInfos = make ([]string , len (cfg .Timezones )+ 1 )
353361 for i := range timeZones {
354362 // Prepare location and time infos
355363 timeInfo := fmt .Sprintf ("%-*s" , descriptionLength , descriptions [i ])
0 commit comments