From 50000481@plink.cityu.edu.hk Mon Feb 19 07:23:15 2001
Received: from plink2.cityu.edu.hk (carol.cityu.edu.hk [144.214.5.208])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f1J6NEZ22097
	for <prolog@swi.psy.uva.nl>; Mon, 19 Feb 2001 07:23:14 +0100 (MET)
Received: from ceciserver (cpct78.cityu.edu.hk)
 by plink2.cityu.edu.hk (Sun Internet Mail Server sims.3.5.1999.03.02.17.58.p5)
 id <0G8Z00801R2CIS@plink2.cityu.edu.hk> for prolog@swi.psy.uva.nl; Mon,
 19 Feb 2001 14:23:01 +0800 (HKT)
Received: from ceciserver (cpct78.cityu.edu.hk)
 by plink2.cityu.edu.hk (Sun Internet Mail Server sims.3.5.1999.03.02.17.58.p5)
 with SMTP id <0G8Z0033LR2BO6@plink2.cityu.edu.hk> for prolog@swi.psy.uva.nl;
 Mon, 19 Feb 2001 14:22:59 +0800 (HKT)
Date: Mon, 19 Feb 2001 14:28:08 +0800
From: Cecilia Wong <50000481@plink.cityu.edu.hk>
To: prolog@swi.psy.uva.nl
Message-id: <001001c09a3d$1fb2d4b0$4e14d690@cityu.edu.hk>
MIME-version: 1.0
X-Mailer: Microsoft Outlook Express 5.50.4133.2400
Content-type: MULTIPART/ALTERNATIVE;
 BOUNDARY="Boundary_(ID_MMlDCaNs9aAlrGr5Wqd++g)"
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
X-Priority: 3
Subject: [SWIPL] keysort

This is a multi-part message in MIME format.

--Boundary_(ID_MMlDCaNs9aAlrGr5Wqd++g)
Content-type: text/plain; charset="big5"
Content-transfer-encoding: quoted-printable

Hi,

    I intend to use the "keysort" predicate to sort a list according to =
one of the arguments in the list.
For example, I have the list, [[a, b, 2], [a, c, 3], [a, b, 1], [b, a, =
5], [d, c, 4], [f, r, 6]]. And I want the=20
resultant list to be sorted like this, [[a, b, 1], [a, b, 2], [a, c, 3], =
[d, c, 4], [b, a, 5], [f, r, 6]], according=20
 to the last argument of the lists in the list. Can this predicate help?

    I am really confused about the syntax of using keysort. As the =
manual stated, "List is a list of=20
Key-Value pairs (e.g. terms of the functor `-' with arity 2)".
Can anyone give an example on how to use this predicate?=20

    Thank you very much!

Cecilia

--Boundary_(ID_MMlDCaNs9aAlrGr5Wqd++g)
Content-type: text/html; charset="big5"
Content-transfer-encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dbig5">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; I intend to use the =
"keysort"=20
predicate to sort a list according to one of the arguments in the=20
list.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>For example, I have the list, [[a, b, =
2], [a, c,=20
3], [a, b, 1], [b, a, 5], [d, c, 4], [f, r, 6]]. And I want the =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>resultant list to be sorted like=20
this,</FONT>&nbsp;<FONT face=3DArial size=3D2>[[a, b, 1], [a, b, 2], [a, =
c,=20
3],&nbsp;[d, c, 4], [b, a, 5],&nbsp;[f, r, 6]], according </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;to the last argument of the lists =
in the=20
list. Can this predicate help?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; I am really confused =

about&nbsp;the syntax of using keysort. As the manual stated, "List is a =
list of=20
</FONT></DIV>
<DIV><FONT face=3DArial><FONT =
size=3D2><CODE><VAR>Key</VAR>-<VAR>Value</VAR></CODE>=20
pairs (e.g. terms of the functor `<CODE><CODE>-</CODE></CODE>' with=20
arity&nbsp;2)".</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Can anyone give an example on how to =
use this=20
predicate?&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Thank you very=20
much!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Cecilia</FONT></DIV></BODY></HTML>

--Boundary_(ID_MMlDCaNs9aAlrGr5Wqd++g)--

