سلام. کد مرتب سازی زیر ، در جاوا وجود دارد :
if (activateTransactionMerging) { Collections.sort(dataset.getTransactions(), new Comparator(){ @Override /** * Compare two transactions */ public int compare(Transaction t1, Transaction t2) { // we will compare the two transaction items by items starting // from the last items. int pos1 = t1.items.length - 1; int pos2 = t2.items.length - 1; // if the first transaction is smaller than the second one if (t1.items.length < t2.items.length) { // while the current position in the first transaction is >0 while (pos1 >= 0) { int subtraction = t2.items[pos2] - t1.items[pos1]; if (subtraction != 0) { return subtraction; } pos1--; pos2--; } // if they ware the same, they we compare based on length return -1; // else if the second transaction is smaller than the first one } else if (t1.items.length > t2.items.length) { // while the current position in the second transaction is >0 while (pos2 >= 0) { int subtraction = t2.items[pos2] - t1.items[pos1]; if (subtraction != 0) { return subtraction; } pos1--; pos2--; } // if they are the same, they we compare based on length return 1; } else { // else if both transactions have the same size while (pos2 >= 0) { int subtraction = t2.items[pos2] - t1.items[pos1]; if (subtraction != 0) { return subtraction; } pos1--; pos2--; } // if they ware the same, they we compare based on length return 0; } } }); }
تا جایی که میدونم بر اساس تابع compare ، تراکنش ها رو مرتب می کنه. روش زیر در کد بالا هست.
چه روشی برای پیاده سازی این تیکه کد زیر در سی شارپ هست ؟
Collections: IComparableCollections.sort(dataset.getTransactions(), new Comparator (){ Override /** * Compare two transactions */ public int compare(Transaction t1, Transaction t2) { /** * Codes */ } });
این پست در تاریخ {{ dateString(new Date(post.deleteDate)) }} توسط {{ post.deletedByUser }} حذف شده است.
دلیل حذف: {{ post.deleteReason ?? 'نامشخص' }}
زمان پاسخ گویی روز های شنبه الی چهارشنبه ساعت 9 الی 18
فقط به موضوعات مربوط به محصولات آموزشی و فروش پاسخ داده می شود