From owner-freebsd-questions@FreeBSD.ORG Mon Oct 3 12:06:06 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC9B8106564A for ; Mon, 3 Oct 2011 12:06:06 +0000 (UTC) (envelope-from mexas@bristol.ac.uk) Received: from dirg.bris.ac.uk (dirg.bris.ac.uk [137.222.10.102]) by mx1.freebsd.org (Postfix) with ESMTP id 87EAB8FC0C for ; Mon, 3 Oct 2011 12:06:06 +0000 (UTC) Received: from ncsc.bris.ac.uk ([137.222.10.41]) by dirg.bris.ac.uk with esmtp (Exim 4.72) (envelope-from ) id 1RAhHN-0005FT-1Y for freebsd-questions@freebsd.org; Mon, 03 Oct 2011 13:06:03 +0100 Received: from mech-cluster241.men.bris.ac.uk ([137.222.187.241]) by ncsc.bris.ac.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1RAhHC-0001dX-Pi for freebsd-questions@freebsd.org; Mon, 03 Oct 2011 13:05:42 +0100 Received: from mech-cluster241.men.bris.ac.uk (localhost [127.0.0.1]) by mech-cluster241.men.bris.ac.uk (8.14.5/8.14.5) with ESMTP id p93C5gTG098936 for ; Mon, 3 Oct 2011 13:05:42 +0100 (BST) (envelope-from mexas@bristol.ac.uk) Received: (from mexas@localhost) by mech-cluster241.men.bris.ac.uk (8.14.5/8.14.5/Submit) id p93C5gRV098935 for freebsd-questions@freebsd.org; Mon, 3 Oct 2011 13:05:42 +0100 (BST) (envelope-from mexas@bristol.ac.uk) X-Authentication-Warning: mech-cluster241.men.bris.ac.uk: mexas set sender to mexas@bristol.ac.uk using -f Date: Mon, 3 Oct 2011 13:05:42 +0100 From: Anton Shterenlikht To: freebsd-questions@freebsd.org Message-ID: <20111003120542.GA98919@mech-cluster241.men.bris.ac.uk> Mail-Followup-To: freebsd-questions@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Subject: cat sort(1) sort floating point numbers? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Oct 2011 12:06:06 -0000 I tried sorting a file with a column of floating point numbers (below) with sort(1) -n. However, the numbers seem to have been sorted by the first digit only. TZAV> cat numbers 3.895686170464136E-016 6.790214437463702E-003 4.163481430190832E-016 2.224131318975909E-002 4.024567914829249E-016 3.538878408636508E-016 9.506347960184421E-016 6.314417282585591E-016 1.026969483958696E-015 1.172673069936531E-015 9.367571020052471E-016 1.110223231422310E-016 1.734778989627912E-015 1.942890368732350E-016 1.117248113958902E-015 1.041412167622504E-015 2.985539431996711E-016 1.728132885863794E-015 2.332566825794786E-015 1.991764744128308E-015 2.290886104875174E-015 1.499379464023130E-015 4.749124883992963E-015 1.526556658859590E-016 1.056173107658783E-015 7.245814328704277E-015 3.819445116003758E-015 2.102152816759188E-015 2.721320602617330E-015 3.223263731968939E-015 1.637578979324018E-015 5.858485627624118E-015 4.442648920965769E-015 1.110244709780361E-015 6.664589960756288E-016 9.761199453440974E-017 1.443557048454884E-015 4.778495371619422E-015 1.947840641841358E-016 5.064931302120728E-016 2.916449385533579E-015 8.400504967177337E-017 1.166250379869858E-015 8.331298074911436E-016 8.337074617781950E-016 1.332719331522803E-015 2.332500698909792E-015 9.104042995697664E-015 1.659811850387433E-014 7.774349986542096E-016 3.610152526999016E-015 5.594426896215451E-017 8.329275106256349E-016 3.830369997864534E-015 3.331392089232636E-016 6.664589971819531E-016 9.325914711054265E-015 1.110226687428913E-016 4.443060083949530E-016 1.388403156535668E-015 5.117876306319294E-016 4.443061859904843E-016 1.593208723602013E-014 2.720931336739666E-015 1.110224674090772E-016 3.916020680284665E-016 1.332269256131286E-014 4.441434721463274E-016 2.886880095386799E-015 1.054917340440720E-015 6.938930742946899E-018 8.659917512448818E-015 4.274409407182516E-015 5.551552273367660E-016 7.549545267281662E-015 9.492612312578653E-015 7.772800489254079E-016 2.554043227849122E-015 7.382990493079966E-015 5.722182748984452E-017 TZAV> sort -n numbers 1.026969483958696E-015 1.041412167622504E-015 1.054917340440720E-015 1.056173107658783E-015 1.110223231422310E-016 1.110224674090772E-016 1.110226687428913E-016 1.110244709780361E-015 1.117248113958902E-015 1.166250379869858E-015 1.172673069936531E-015 1.332269256131286E-014 1.332719331522803E-015 1.388403156535668E-015 1.443557048454884E-015 1.499379464023130E-015 1.526556658859590E-016 1.593208723602013E-014 1.637578979324018E-015 1.659811850387433E-014 1.728132885863794E-015 1.734778989627912E-015 1.942890368732350E-016 1.947840641841358E-016 1.991764744128308E-015 2.102152816759188E-015 2.224131318975909E-002 2.290886104875174E-015 2.332500698909792E-015 2.332566825794786E-015 2.554043227849122E-015 2.720931336739666E-015 2.721320602617330E-015 2.886880095386799E-015 2.916449385533579E-015 2.985539431996711E-016 3.223263731968939E-015 3.331392089232636E-016 3.538878408636508E-016 3.610152526999016E-015 3.819445116003758E-015 3.830369997864534E-015 3.895686170464136E-016 3.916020680284665E-016 4.024567914829249E-016 4.163481430190832E-016 4.274409407182516E-015 4.441434721463274E-016 4.442648920965769E-015 4.443060083949530E-016 4.443061859904843E-016 4.749124883992963E-015 4.778495371619422E-015 5.064931302120728E-016 5.117876306319294E-016 5.551552273367660E-016 5.594426896215451E-017 5.722182748984452E-017 5.858485627624118E-015 6.314417282585591E-016 6.664589960756288E-016 6.664589971819531E-016 6.790214437463702E-003 6.938930742946899E-018 7.245814328704277E-015 7.382990493079966E-015 7.549545267281662E-015 7.772800489254079E-016 7.774349986542096E-016 8.329275106256349E-016 8.331298074911436E-016 8.337074617781950E-016 8.400504967177337E-017 8.659917512448818E-015 9.104042995697664E-015 9.325914711054265E-015 9.367571020052471E-016 9.492612312578653E-015 9.506347960184421E-016 9.761199453440974E-017 Is this the expected behaviour? If yes, can sort(1) be at all used to sort float. point numbers? Many thanks Anton -- Anton Shterenlikht Room 2.6, Queen's Building Mech Eng Dept Bristol University University Walk, Bristol BS8 1TR, UK Tel: +44 (0)117 331 5944 Fax: +44 (0)117 929 4423