数据阵列:
java.lang.IncompatibleClassChangeError: Class com.google.android.gms.a.b implements non-interface class com.google.android.gms.a.a (declaration of 'com.google.android.gms.a.b' appears in /data/data/com.google.android.gms/app_chimera/chimera-module-root/module-dd5b1d6850a09abe29b143730d133d3d1f4c4971/MapsModule.apk)
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:240)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:233)
at dalvik.system.DexPathList.findClass(DexPathList.java:321)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.google.android.gms.maps.internal.h.onTransact(SourceFile:104)
at android.os.Binder.transact(Binder.java:380)
at com.google.android.gms.maps.internal.ah.a(SourceFile:256)
at com.google.android.gms.maps.internal.CreatorImpl.a(SourceFile:82)
at com.google.android.gms.maps.internal.CreatorImpl.b(SourceFile:96)
at com.google.android.gms.maps.internal.ag.onTransact(SourceFile:62)
at android.os.Binder.transact(Binder.java:380)
at com.google.android.gms.maps.a.al.b(Unknown Source)
at com.google.android.gms.maps.q.g(Unknown Source)
at com.google.android.gms.maps.q.a(Unknown Source)
at com.google.android.gms.b.b.a(Unknown Source)
at com.google.android.gms.b.b.a(Unknown Source)
at com.google.android.gms.maps.n.onCreate(Unknown Source)
at android.support.v4.app.Fragment.performCreate(SourceFile:1766)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:917)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1138)
at android.support.v4.app.BackStackRecord.run(SourceFile:740)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(SourceFile:1501)
at android.support.v4.app.FragmentActivity.onStart(SourceFile:551)
树枝的结果:
$allEvents = [];
foreach ($events as $event) {
$allEvents[] = $event;
}
foreach ($user->getEvents() as $event) {
$allEvents[] = $event;
}
var_dump allEvents结果:
return $this->render(
'MyBundle:User:dashboard.html.twig',
[ 'allEvents' => $allEvents,
'user' => $user ]
);
问题:如何通过计划(有些像ASC或DESC排序)对数组进行排序?
答案 0 :(得分:1)
您可以使用PHP的usort功能,如下所示(我已经编辑了答案,让您看得更清楚):
修改强>
$allSortedEvents = usort( $allEvents, function( $a, $b ){
if ( $a->getSchedule() == $b->getSchedule() )
{
return 0;
}
else
{
return ( $a->getSchedule() < $b->getSchedule() ) ? -1 : 1;
}
});
发送给Twig:
return $this->render(
'MyBundle:User:dashboard.html.twig',
[ 'allEvents' => $allSortedEvents,
'user' => $user ]
);