[SOLVED] sorting 101. table file cars does not sort correctly?
Focus 101 sorting. Here is my code TABLE FILE CAR PRINT COUNTRY CAR MODEL BODYTYPE LENGTH BY LENGTH BY BODYTYPE END
This is a simple program, but on the seventh and eighth line, why does SEDAN appear before COUPE? 'C' comes before 'S'.
PAGE 1 LENGTH BODYTYPE COUNTRY CAR MODEL BODYTYPE LENGTH 163 SEDAN JAPAN DATSUN B210 2 DOOR AUTO SEDAN 163 163 COUPE ITALY ALFA ROMEO 2000 GT VELOCE COUPE 163 165 HARDTOP ENGLAND TRIUMPH TR7 HARDTOP 165 165 SEDAN JAPAN TOYOTA COROLLA 4 DOOR DIX AUTO SEDAN 165 170 ROADSTER ITALY ALFA ROMEO 2000 SPIDER VELOCE ROADSTER 170 176 SEDAN W GERMANY BMW 2002 2 DOOR SEDAN 176 W GERMANY BMW 2002 2 DOOR AUTO SEDAN 176 177 SEDAN ITALY ALFA ROMEO 2000 4 DOOR BERLINA SEDAN 177 177 COUPE ITALY MASERATI DORA 2 DOOR COUPE 177 182 SEDAN FRANCE PEUGEOT 504 4 DOOR SEDAN 182 187 SEDAN W GERMANY AUDI 100 LS 2 DOOR AUTO SEDAN 187This message has been edited. Last edited by: FP Mod Chuck,
WebFocus 8201M Windows Excel
March 20, 2018, 11:44 AM
FP Mod Chuck
Hi Jrbrown00
First of all welcome to Focal Point, it is a great forum to get answers to your development questions...
The only thing I can figure is that the CAR database is hierarchical and the LENGTH field is in a child segment of the BODYTYPE field. When I changed your report to SEATS instead of LENGTH it sorted as you would expect and that field is in the same segment as BODYTYPE. If I used any of the other fields under the SPECS segment it does sort weird.
Anyone else have an explantion for this?
Thank you for using Focal Point!
Chuck Wolff - Focal Point Moderator WebFOCUS 7x and 8x, Windows, Linux All output Formats
March 20, 2018, 12:40 PM
jcannavo
Not sure that's it Chuck. Sorting worked just fine when I use FUEL_CAP, RPM, MPG, or BHP from the SPECS, but not for Length or Width. This is interesting behavior. Perhaps in the background length and width are indexed differently?
JC WebFOCUS Dev Studio / App Studio 8.2.01 Windows 7
March 20, 2018, 01:18 PM
BabakNYC
CAR is a multi-Seg FOCUS file. I don't know for sure but could it have something to do with the fact that BODYTYPE is in a higher segment than LENGTH in the master file?
WebFOCUS 8206, Unix, Windows
March 20, 2018, 01:56 PM
Francis Mariani
Try this:
TABLE FILE CAR
PRINT COUNTRY CAR MODEL BODYTYPE LENGTH/P8.2
BY LENGTH
BY BODYTYPE
END
You will be surprised
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
March 20, 2018, 02:11 PM
FP Mod Chuck
Very interesting the value for length is larger because of the decimal value and therefore is sorting correctly...
Thank you for using Focal Point!
Chuck Wolff - Focal Point Moderator WebFOCUS 7x and 8x, Windows, Linux All output Formats
March 20, 2018, 03:08 PM
jcannavo
quote:
LENGTH/P8.2
LOL, I was going to try that, but thought nah and decided to move onto something else.
JC WebFOCUS Dev Studio / App Studio 8.2.01 Windows 7
March 20, 2018, 03:30 PM
Francis Mariani
quote:
nah
I'm a stickler for punishment.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server