给出Clojure中的以下列表:
#include "math.h"
#include "malloc.h"
#include "stdlib.h"
#include "stdio.h"
#include "subroutines.h"
// Libreria para resolver sistemas lineales.
static double *sub_diag, * sup_diag, *diag, *d ;
// Function which allocates memory for the variables used inside the interpolation method
void inimem_spline(int n)
{
int r = n-2, c = n-2;
int i, j;
d=(double *) calloc(n,sizeof(double));
if(d==NULL) {
printf("\ninimem_spline:It is not possible to allocate memory\n");
exit(19);
}
for(j=0;j<n;j++) d[j]=0.e+0;
sub_diag=(double *) calloc(n-1,sizeof(double));
if(sub_diag==NULL) {
printf("\ninimem_spline:It is not possible to allocate memory\n");
exit(20);
}
for(j=0;j<n;j++) sub_diag[j]=0.e+0;
sup_diag=(double *) calloc(n-1,sizeof(double));
if(sup_diag==NULL) {
printf("\ninimem_spline:It is not possible to allocate memory\n");
exit(21);
}
for(j=0;j<n;j++) sup_diag[j]=0.e+0;
diag=(double *) calloc(n,sizeof(double));
if(diag==NULL) {
printf("\ninimem_spline:It is not possible to allocate memory\n");
exit(22);
}
for(j=0;j<n;j++) diag[j]=0.e+0;
}
// Free Space of the Variables used inside the interpolation method.
void freemem_spline(int n)
{
int i,j;
for(j=0;j<n;j++) free(sub_diag[j]);
for(j=0;j<n;j++) free(sup_diag[j]);
for(j=0;j<n;j++) free(diag[j]);
for(j=0;j<n;j++) free(d[j]);
printf("\freemem_spline:Memmory free\n");
}
我想根据每对中的第二项按降序对它们进行排序。
即我希望它们分类为:
(def pairs '[(2,1),(3,2),(2,4)])
我的问题是:如何根据嵌套值对列表中的对进行排序?
答案 0 :(得分:4)
使用sort-by
:
(sort-by second > pairs)