الفرق بين المراجعتين ل"Kotlin/collections/sortDescending"
< Kotlin | collections
اذهب إلى التنقل
اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: الدالة <code>sortDescending()</code> في لغة Kotlin}}</noinclude> تقوم الدالة<code>sortDescending()</code> بترت...') |
|||
سطر 1: | سطر 1: | ||
<noinclude>{{DISPLAYTITLE: الدالة <code>sortDescending()</code> في لغة Kotlin}}</noinclude> | <noinclude>{{DISPLAYTITLE: الدالة <code>sortDescending()</code> في لغة Kotlin}}</noinclude> | ||
− | تقوم الدالة<code>sortDescending()</code> بترتيب [[Kotlin/Array|المصفوفة]] أو [[kotlin/MutableList|اللائحة المتغيرة]] (<code>MutableList</code>) التي استُدعيت عبرها. | + | تقوم الدالة<code>sortDescending()</code> بترتيب [[Kotlin/Array|المصفوفة]] أو [[kotlin/MutableList|اللائحة المتغيرة]] (<code>MutableList</code>) التي استُدعيت عبرها تنازليًا. |
==البنية العامة== | ==البنية العامة== | ||
− | + | يمكن استدعاء الدالة <code>sortDescending()</code> عبر [[Kotlin/Array|المصفوفات]] فستقوم بترتيبها: <nowiki/><nowiki/><syntaxhighlight lang="kotlin"> | |
− | + | fun <T : Comparable<T>> Array<out T>.sortDescending() | |
− | + | fun ByteArray.sortDescending() | |
− | + | fun ShortArray.sortDescending() | |
− | + | fun IntArray.sortDescending() | |
− | + | fun LongArray.sortDescending() | |
− | + | fun FloatArray.sortDescending() | |
− | + | fun DoubleArray.sortDescending() | |
− | + | fun CharArray.sortDescending() | |
− | + | </syntaxhighlight>يمكن<nowiki/><nowiki/> استدعاء الدالة <code>sortDescending()</code> عبر كائن من النوع <code>[[kotlin/MutableList|MutableList]]</code>:<nowiki/><nowiki/><syntaxhighlight lang="kotlin"> | |
− | + | fun <T : Comparable<T>> MutableList<T>.sortDescending() | |
− | |||
− | |||
− | |||
− | fun ByteArray. | ||
− | fun ShortArray. | ||
− | fun IntArray. | ||
− | fun LongArray. | ||
− | fun FloatArray. | ||
− | fun DoubleArray. | ||
− | fun CharArray. | ||
− | |||
− | </syntaxhighlight> | ||
− | |||
− | |||
− | fun <T : Comparable<T>> MutableList<T>. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | </syntaxhighlight> | ||
==أمثلة== | ==أمثلة== | ||
===استخدام الدالة <code>()sortDescending</code> مع المصفوفات=== | ===استخدام الدالة <code>()sortDescending</code> مع المصفوفات=== | ||
− | تعرف الشيفرة الآتية <nowiki/>[[Kotlin/Array|مصفوفة]]<nowiki/>باسم <code>array</code> مكونة من ستة عناصر باستخدام الدالة <code>()arrayOf</code>، ثم تستخدم الدالة<code>()sortDescending</code> على <code>array</code> | + | تعرف الشيفرة الآتية <nowiki/>[[Kotlin/Array|مصفوفة]]<nowiki/>باسم <code>array</code> مكونة من ستة عناصر باستخدام الدالة <code>()arrayOf</code>، ثم تستخدم الدالة<code>()sortDescending</code> على <code>array</code> لترتيبه تنازليًا، ثم تطبع الناتج:<syntaxhighlight lang="kotlin"> |
import java.util.Arrays | import java.util.Arrays | ||
fun main(args: Array<String>) { | fun main(args: Array<String>) { | ||
− | val array = arrayOf(1, 9, 3, 7, 5, 6) | + | val array = arrayOf(1, 9, -3, 7, 5, 6) |
− | + | array.sortDescending() | |
− | array. | ||
− | print (Arrays.toString(array)) // [ | + | print (Arrays.toString(array)) // [9, 7, 6, 5, 1, -3] |
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==أنظر أيضًا== | ==أنظر أيضًا== | ||
*<code>[[Kotlin/collections/sortBy|sortBy()]]</code> : تقوم بترتيب [[Kotlin/Array|المصفوفة]] أو [[Kotlin/MutableList|اللائحة المتغيرة]] (<code>MutableList</code>) التي استُدعيت عبرها وفقًا للقيم التي تعيدها الدالة المُمرّرة . | *<code>[[Kotlin/collections/sortBy|sortBy()]]</code> : تقوم بترتيب [[Kotlin/Array|المصفوفة]] أو [[Kotlin/MutableList|اللائحة المتغيرة]] (<code>MutableList</code>) التي استُدعيت عبرها وفقًا للقيم التي تعيدها الدالة المُمرّرة . | ||
+ | |||
+ | * <code>[[Kotlin/collections/sort|sort()]]</code> : تقوم بترتيب <nowiki/>[[Kotlin/Array|المصفوفة]] أو اللائحة المتغيرة (<code>MutableList</code>) التي استُدعيت عبرها. | ||
+ | * | ||
+ | |||
==مصادر== | ==مصادر== | ||
− | *[https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/sort.html الدالة sortDescending() في التوثيق الرسميّ للمكتبة القياسيّة في لغة Kotlin.] | + | *[https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/sort-descending.html الدالة sortDescending() في التوثيق الرسميّ للمكتبة القياسيّة في لغة Kotlin.] |
[[تصنيف:Kotlin]] | [[تصنيف:Kotlin]] | ||
[[تصنيف:Kotlin Functions]] | [[تصنيف:Kotlin Functions]] |
مراجعة 18:15، 6 يونيو 2018
تقوم الدالةsortDescending()
بترتيب المصفوفة أو اللائحة المتغيرة (MutableList
) التي استُدعيت عبرها تنازليًا.
البنية العامة
يمكن استدعاء الدالة sortDescending()
عبر المصفوفات فستقوم بترتيبها:
fun <T : Comparable<T>> Array<out T>.sortDescending()
fun ByteArray.sortDescending()
fun ShortArray.sortDescending()
fun IntArray.sortDescending()
fun LongArray.sortDescending()
fun FloatArray.sortDescending()
fun DoubleArray.sortDescending()
fun CharArray.sortDescending()
يمكن استدعاء الدالة sortDescending()
عبر كائن من النوع MutableList
:
fun <T : Comparable<T>> MutableList<T>.sortDescending()
أمثلة
استخدام الدالة ()sortDescending
مع المصفوفات
تعرف الشيفرة الآتية مصفوفةباسم array
مكونة من ستة عناصر باستخدام الدالة ()arrayOf
، ثم تستخدم الدالة()sortDescending
على array
لترتيبه تنازليًا، ثم تطبع الناتج:
import java.util.Arrays
fun main(args: Array<String>) {
val array = arrayOf(1, 9, -3, 7, 5, 6)
array.sortDescending()
print (Arrays.toString(array)) // [9, 7, 6, 5, 1, -3]
}
أنظر أيضًا
sortBy()
: تقوم بترتيب المصفوفة أو اللائحة المتغيرة (MutableList
) التي استُدعيت عبرها وفقًا للقيم التي تعيدها الدالة المُمرّرة .