Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1siyfX-00C6DL-O3 for pgsql-sql@arkaria.postgresql.org; Tue, 27 Aug 2024 16:03:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1siyfV-009EiK-Hw for pgsql-sql@arkaria.postgresql.org; Tue, 27 Aug 2024 16:03:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1siyfV-009EgR-8O for pgsql-sql@lists.postgresql.org; Tue, 27 Aug 2024 16:03:41 +0000 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1siyfS-001mVA-H0 for pgsql-sql@lists.postgresql.org; Tue, 27 Aug 2024 16:03:41 +0000 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3db51133978so546409b6e.3 for ; Tue, 27 Aug 2024 09:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724774618; x=1725379418; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iNBVR5sDuIWLcOc+1+cVlRwsojIhvUOBVJEGFeehhD0=; b=eZheHyV7984+zFq8rjlX2/0M+1KQG8BNCbyt11auxX3GObLyuwSeqk+m6j/tihSOVC TyWVIVYAeXZcg0hweftiOU3bu81ZAleVc+CMlovT+uBZSPyFI3/l9Fk+YKZd9fuP2uZh H6dz4SHr58wkyvtJ5dmRkyeVVCw+bQPA8q0rk3wet9IjnT2YzMl3lhfmK7mH5XJdJah6 WFEzWXgf72pSAcKvJbUJfK62nHCuZUd6/DhyG36q//lbQtlfTxG4w3i3l8F/x58yLv5H FlRSKOmIYO/UCNr43IpTLyCJRMUZSei6sf95a+MWh193ivFwKgmOaf2vyx4HdxQ+SZIF Preg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724774618; x=1725379418; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iNBVR5sDuIWLcOc+1+cVlRwsojIhvUOBVJEGFeehhD0=; b=YovOozlxvtnY30lkBq0uwUQdojRbeUaxuMwR+xzl7h4kRoNMawA53DsWpFEzzJ1cfM Stte5xIFu62FpYfHrcK+nzynbPXiJ+Dz09PZQjelX3wCrEXzeSiKUeBLL0E9X6fKO0xy szxXXyualv/ru1FqjtXu83ivcSOq0V99WcS0LGgP/u8BjFqcbDta4O8Vk7BxNbyVYWh7 uO/ZFt/6kn3GwW5CEDJKZes69/t9LHJNhT2lAgzdUsasRPXstcUgkTQKLvx+iV4LEuK6 kZu1zZ75uZgeRXxha0CIRwvR4t49wuyS+PFi/NXGcEXIHFsj9w2zVC0um2cHMrPYj+ZP XjCg== X-Gm-Message-State: AOJu0Yyp3aLD1/n32Gm8NhegN16U7DvS4UEkSg8MMz562Gd7r0Xy8MHe Lf+5N2YYFMWQrN32j7JmvSC75AoL6eIYJRDbi6IBxqbe4iT1plSVDWsfsR8FS74GgiNolHjlgYT perLpHEDhvDN11pkaKRraojtffHlUt6MlRGA= X-Google-Smtp-Source: AGHT+IGHi4QOBosyhIsaEfksaYHpqKQz8/fnY1raZRtUCs2ChHRuZ0L2kgaPCt8bHlb8m1qfQb5Ky9pLh1lQdSmS5zM= X-Received: by 2002:a05:6870:a551:b0:261:877:7459 with SMTP id 586e51a60fabf-2775a035f03mr3897896fac.38.1724774617807; Tue, 27 Aug 2024 09:03:37 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:5e88:0:b0:557:c384:fb61 with HTTP; Tue, 27 Aug 2024 09:03:37 -0700 (PDT) In-Reply-To: References: From: "David G. Johnston" Date: Tue, 27 Aug 2024 09:03:37 -0700 Message-ID: Subject: Re: ORDER BY elements in ARRAY To: Andreas Joseph Krogh Cc: "pgsql-sql@lists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000006985090620ac62b6" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006985090620ac62b6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tuesday, August 27, 2024, Andreas Joseph Krogh wrote: > P=C3=A5 tirsdag 27. august 2024 kl. 14:39:34, skrev David G. Johnston < > david.g.johnston@gmail.com>: > > [=E2=80=A6] > Add order by here > >> ) as person_array >> >> FROM onp_crm_relation comp >> ORDER BY person_array >> ; >> >> > David J. > > > > This doesn't really do it. I'm looking for something analogous to Java's > Comparator-interface so the custom datatype knows how to sort itself. > Ah. Then either just put those two values into the first two field positions of your custom type and live with an easy, but also self-contained, hack, or figure out what incantations of create operator and/or create operator family are need to install custom behavior for the b-tree < and > operators. I=E2=80=99m 80% sure it=E2=80=99s doable, 60% in= plpgsql=E2=80=A6 David J. --0000000000006985090620ac62b6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tuesday, August 27, 2024, Andreas Joseph Krogh <andreas@visena.com> wrote:
P=C3=A5 tirsdag 27. august 2024 kl. 14:39:34, skrev David G.= Johnston <david.g.johnston@gmail.com>:

= [=E2=80=A6]

Add order by here=C2=A0
       ) as person_array

FROM onp_crm_relation comp
ORDER BY person_array
;
=C2=A0
David J.

=C2=A0

This doesn't really do it. I'm looking for somethi= ng analogous to Java's Comparator-interface so the custom = datatype knows how to sort itself.


Ah.= =C2=A0 Then either just put those two values into the first two field posit= ions of your custom type and live with an easy, but also self-contained, ha= ck, or figure out what incantations of create operator and/or create operat= or family are need to install custom behavior for the b-tree < and > = operators.=C2=A0 I=E2=80=99m 80% sure it=E2=80=99s doable, 60% in plpgsql= =E2=80=A6

David J.

--0000000000006985090620ac62b6--